Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Octokit example not working for "Update a webhook configuration for a repository" #9900

Closed
1 task done
fabzo opened this issue Sep 8, 2021 · 2 comments
Closed
1 task done
Labels
content This issue or pull request belongs to the Docs Content team triage Do not begin working on this issue until triaged by the team

Comments

@fabzo
Copy link

fabzo commented Sep 8, 2021

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/rest/reference/repos#update-a-webhook-configuration-for-a-repository

What part(s) of the article would you like to see updated?

The current example code reads as follows:

await octokit.request('PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config', {
  owner: 'octocat',
  repo: 'hello-world',
  hook_id: 42,
  url: 'url'
})

But Octokit will interpret all first level attributes of the options object as configuration parameters if applicable. From my understanding it will take the 'url' attribute from the options object and ignore the request path. See https://github.com/octokit/endpoint.js/blob/master/src/merge.ts#L14 as well as https://github.com/octokit/endpoint.js/blob/master/src/parse.ts#L76

The example resulted in my code trying to send the request to the provided webhook URL instead of the GitHub API.

The working code looks as follows:

await octokit.request('PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config', {
  owner: 'octocat',
  repo: 'hello-world',
  data: {
    hook_id: 42,
    url: 'url'
  }
})

Unfortunately I could not find the location of the code example in the documentation and thus was unable to propose a change directly.

Additional information

No response

@fabzo fabzo added the content This issue or pull request belongs to the Docs Content team label Sep 8, 2021
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Sep 8, 2021
@fabzo fabzo changed the title Octokit Example not working for "Update a webhook configuration for a repository" Octokit example not working for "Update a webhook configuration for a repository" Sep 8, 2021
@gr2m
Copy link
Contributor

gr2m commented Sep 9, 2021

Hi 👋🏼 Octokit.js maintainer here

This endpoint is unfortunately a special case. It did not exist when I created octokit.request originally. I think it would make sense to change Octokit's behavior at this point, I created a follow up issue here so you can track it. octokit/request.js#425

The Octokit examples are generated, some of them are not quite correct. Adding manual overwrites would introduce quite a lot of complexity and maintenance overhead, I'd rather not do that, but wait for me to address the problem with the url parameter in Octokit itself

@skedwards88
Copy link
Contributor

Thanks for following up @gr2m and thanks for opening this issue @fabzo ! Since this will be fixed in the octokit repo, I am going to close out this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content This issue or pull request belongs to the Docs Content team triage Do not begin working on this issue until triaged by the team
Projects
None yet
Development

No branches or pull requests

3 participants