fix: reject replayed webhook deliveries - #22
Merged
TheGreatAxios merged 1 commit intoSep 27, 2026
Conversation
TheGreatAxios
added this pull request to stack #18
September 27, 2026 02:15
Key Standard Webhooks on (credential, webhook-id) and Slack on (credential, signature) in a Postgres seen-set shared by replicas. The webhooks.replay table ships as a migration, run by runWebhookMigrations from @corbits/webhooks/migrations. Refs CL-9450.
TheGreatAxios
force-pushed
the
cl-9450-webhooks-reject-replayed-deliveries
branch
from
September 27, 2026 02:20
231e9a1 to
0b0ee54
Compare
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.
Closes CL-9450
Stacked on #21.
(credentialId, webhook-id)for Standard Webhooks and(credentialId, signature)for Slack. A repeat gets409 { "error": "replayed" }.webhooks.replay(credential_idFK to the host'scredentialtable withON DELETE CASCADE,nonce,expires_at; primary key(credential_id, nonce); index onexpires_at). It ships asmigrations/0001_webhooks.sql, applied byrunWebhookMigrations(dbConfig, { schema })from@corbits/webhooks/migrations: idempotent, one transaction underpg_advisory_xact_lock, the same pattern as@corbits/agent-token. The route assumes the migration ran; there is no runtime DDL.INSERT … ON CONFLICT DO UPDATE … WHERE expired RETURNING, which is atomic across replicas; expired rows are purged on each claim.@corbits/agent-token:drizzle-orm(^0.45.1, the range@intx/dbalready uses;src/builds the replay queries with it on the host'sdb) andpostgres(^3.4.8, used by the migration runner).Tests: a unit replay (Slack) and retry-after-failure; an e2e that sends one Standard Webhooks request to two apps sharing the database and gets
202then409; and an e2e that runsrunWebhookMigrationsfrom three concurrent runners on a throwaway database and checks the FK and expiry index. CI's pack smoke also imports@corbits/webhooks/migrations.