Repository navigation
fix(setup): register again a webhook deleted at the service - #100
Merged
Merged
Conversation
On a re-run with nothing changed, setup reported `webhook existing`
whenever a webhook id was saved in the source description, without
asking the service. A GitHub webhook deleted on the repository left
setup exiting 0 with no webhook, so no events arrived (seen on 5 Nov).
Source definitions get an optional `webhookExists`. Setup calls it
before reporting `existing`: false registers the webhook again, as on
a first run, and reports `registered`; a rejection (a key or token that
can't read webhooks, the network) keeps the saved webhook and logs a
warning. Resend checks GET /webhooks/{id} (404 means deleted). GitHub
lists each repository's (or the organization's) webhooks and looks for
one delivering to the source URL, since it stores no ids; the source's
secret is reused, so the other repositories' webhooks keep verifying.
Sources without `webhookExists` keep today's behavior.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-running
setupreportedwebhook existingfor a GitHub or Resend source whose webhook had been deleted at the service, so no events arrived (seen on 5 Nov). Setup now checks the saved webhook first: if it's gone, it registers it again and reportsregistered; if it can't check, it keeps the saved webhook, reportsexisting, and logs a warning.Changes and testing
Changes
webhookExistson source definitions (src/core/sources/types.ts): optional. Resolving false makes setup register the webhook again; rejecting makes setup keep it and warn. Sources without it keep today's behavior.src/core/sources/resend.ts):GET /webhooks/{id}; 404 means deleted, other failures reject.src/core/sources/github.ts): the bridge stores no webhook ids for GitHub (it matches webhooks by source URL), so the check lists each repository's (or the organization's) webhooks and looks for one delivering to the source URL. GitHub's 404 for a repository the token can't see rejects rather than counting as deleted. Manual mode makes no call.src/core/setup.ts): on a re-run with nothing changed, it checks before reportingexisting. A missing webhook logsthe <service> webhook saved on bridge-<id> is missing at <service>; registering it againand is registered as on a first run, without unregistering the old id. The source's secret is offered for reuse, so GitHub's remaining webhooks keep verifying. A failed check logswarning: could not confirm the <service> webhook saved on bridge-<id> still exists, so keeping it: <error>.docs/ARCHITECTURE.md(source definition, GitHub), andCHANGELOG.md(Unreleased > Fixed).Testing
npx tsc --noEmitandnpx vitest runpass (431 tests, 35 files).existing, one check), deleted (registered again, new id and secret saved for Resend, same secret kept for GitHub, nothing deleted), and check failing with 401 or 403 (warning,existing). Unit tests for each source'swebhookExists.FakeGithubtreats owner and repository names case-insensitively, as GitHub does, and can fail every request with a given status.GET /webhooks/{id}for a webhook that doesn't exist returns404with{"name":"not_found","message":"Webhook endpoint not found"}, whichwebhookExiststreats as deleted. The live GitHub case runs in the release's cold test.🤖 Generated with Claude Code