gr2m / gr2m/github-app-webhook-relay
Handle "Hook already exists on this repository" error
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Example error
```js
{
status: 422,
response: {
url: 'https://api.github.com/repos/my-owner/my-repo/hooks',
status: 422,
headers: {
// ...
},
data: {
message: 'Validation Failed',
errors: [
{
resource: 'Hook',
code: 'custom',
message: 'Hook already exists on this repository'
}
],
documentation_url: 'https://docs.github.com/rest/webhooks/repos#create-a-repository-webhook'
}
},
request: {
method: 'POST',
url: 'https://api.github.com/repos/hearts-testing/test/hooks',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': '...',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: '{"name":"cli","events":["issues"],"config":{"content_type":"json","insecure_ssl":"0"}}',
request: { hook: [Function: bound bound register] }
}
}
```
We should instead throw a more helpful error with a link to where the user can delete the token manually. We might even find out more about the created webhook token, and if it was created by the same user, we might consider deleting and re-creating it transparently
Contributor guide
Assessment
This issue has not been assessed yet.