Skip to content

fix(setup): register again a webhook deleted at the service - #100

Merged
leggetter merged 1 commit into
mainfrom
fix/setup-deleted-webhook
Nov 5, 2026
Merged

leggetter merged 1 commit into
mainfrom
fix/setup-deleted-webhook

Conversation

@leggetter

Copy link
Copy Markdown
Collaborator

Re-running setup reported webhook existing for 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 reports registered; if it can't check, it keeps the saved webhook, reports existing, and logs a warning.

Changes and testing

Changes

  • webhookExists on 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.
  • Resend (src/core/sources/resend.ts): GET /webhooks/{id}; 404 means deleted, other failures reject.
  • GitHub (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.
  • Setup (src/core/setup.ts): on a re-run with nothing changed, it checks before reporting existing. A missing webhook logs the <service> webhook saved on bridge-<id> is missing at <service>; registering it again and 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 logs warning: could not confirm the <service> webhook saved on bridge-<id> still exists, so keeping it: <error>.
  • Docs: the skill's setup success signal and troubleshooting, the README (re-running setup, troubleshooting), docs/ARCHITECTURE.md (source definition, GitHub), and CHANGELOG.md (Unreleased > Fixed).

Testing

  • npx tsc --noEmit and npx vitest run pass (431 tests, 35 files).
  • New setup tests, for Resend and GitHub: webhook present (still 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's webhookExists.
  • The 7 new or changed tests fail without the fix.
  • FakeGithub treats owner and repository names case-insensitively, as GitHub does, and can fail every request with a given status.
  • Resend, checked live on 5 Nov: GET /webhooks/{id} for a webhook that doesn't exist returns 404 with {"name":"not_found","message":"Webhook endpoint not found"}, which webhookExists treats as deleted. The live GitHub case runs in the release's cold test.

🤖 Generated with Claude Code

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>
@leggetter
leggetter merged commit fc53480 into main Nov 5, 2026
2 checks passed
@leggetter
leggetter deleted the fix/setup-deleted-webhook branch November 5, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant