Guides · duplicate delivery
Test webhook idempotency without losing valid events
A stock adjustment arrives twice. A handler that treats each delivery as a new event can record the adjustment twice. Check that the duplicate records one adjustment and a separate valid event still gets through.
Deliver the same event twice
Choose a deduplication key, then send both attempts for event A and one distinct event B. The expected local intent total is +5 units.
INVENTORY · ITEM RECORD
Adjustment queue
item_demo_001- Event source
- source_alpha
- Account
- acct_one
Local outbox intents
0No adjustments queued.
Delivery inspector
0 / 3 receivedDelivery sequence
- 1evt_AFirst attempt
- 2evt_ASecond attempt
- 3evt_BDistinct event
Send the first delivery to inspect its logical event, scoped key and local handler result.
This browser model uses the first three events from the downloadable SQLite exercise. The projection counts local intents only. No inventory is updated.
Keep the event stable while attempts change
Authored local transaction · expected identity boundary
Logical event key
source + account + event_idKeep this identity stable across retries of the same event.
Delivery attempts
Attempt A
Attempt B
Different attempt IDs carry the same logical event.
One local SQLite transaction
Inbox identity + one outbox intent
Record acceptance and the intended adjustment together.
Your event key needs the scope that makes it unique. In this exercise, each attempt has a separate attempt ID; a resource ID can be shared by several legitimate events. Neither is automatically the right event key. The Standard Webhooks specification distinguishes a stable message identifier from changing retry timestamps. The attempt IDs and source/account fields here are authored fixture scope, not authenticated provider claims.
Check the identity policy with rejecting controls
Keep one intended action for a repeated logical event while preserving distinct events for the same resource. Compare the correct scoped event key with wrong attempt-ID and resource-ID keys, then check payload conflicts and interrupted transactions.
The duplicate-delivery example in the webhook documentation contains the Python/SQLite download, command, full control matrix and expected local ledger observations. It checks local inbox/outbox intents, not provider delivery or external exactly-once effects.
Move the assertions to your own effect boundary
- Define the identity and conflict policy. Derive source/account scope from trusted producer or authentication context in your real handler; the fixture envelope does not authenticate it. Name the event ID and payload comparison. Decide what changed content under the same key means; preserve the original accepted event. AWS’s idempotency guidance explains scoped identifiers and changed-intent handling.
- Keep the durable records together. Adapt the inbox and intended-action write to the transaction your handler actually owns. If dispatch is separate, define its idempotency and reconciliation rather than inferring them from an outbox row.
- Keep both rejecting controls. Duplicate attempts must not add another intended effect. Distinct legitimate events for the same resource must not disappear. Include cross-source/account and payload-conflict cases.
- Retain the observed evidence. Keep event/attempt identities, stored payload identity, committed intents, acknowledgement and the actual downstream result when testing a real dispatcher.
The owned child-process exits exercise local restart boundaries around SQLite’s atomic commit. The postcommit case exits only after commit returns successfully. If commit fails or never returns, the caller outcome is unknown: reopen and resolve it through the logical key. Concurrency, power loss, ordering, retention of event keys and an external dispatcher's behavior need their own tests at the relevant persistence/effect boundary.
Add HTTP only for the callback path you need
An in-process consumer test can answer the local identity question. The download does not expose an HTTP receiver; provide your own safe test endpoint if you add replay. To deliver a selected UTF-8 callback over HTTP, Gostly can retain a capture and manually replay its stored text to an approved, API-reachable test receiver. Follow the capture-versus-replay boundary and the explicit replay instructions.
A Gostly capture ID identifies the retained delivery record, not your consumer's logical event. Replaying the same stored capture can reuse that capture ID; your test driver owns any separate attempt identity. Confirm the actual target response and durable application result. Replay does not add the consumer transaction or deduplication policy shown here.