Lesson 9 of 9 · 25m
Testing, Replays, and Webhook Incident Operations
Test duplicate, stale, malformed, and reordered deliveries; operate backfills and incidents with replay tools, reconciliation, and clear customer communication.
Webhook systems rarely fail as a clean binary. They degrade: one endpoint saturates, one schema migration creates poison messages, one consumer deploy rejects valid signatures, one queue silently ages. If your only test is "send a sample event and see 200," you have tested the sunny path and learned almost nothing. Mature teams rehearse duplicates, disorder, delay, and recovery before production does it for them.
Test the failures that are guaranteed
A minimum webhook test matrix includes:
duplicate delivery same timestamp/body
same event redelivered with a new delivery attempt
stale timestamp outside the allowed window
missing signature and malformed signature
valid signature for an old rotated secret during overlap
unknown future event type
out-of-order object transitions
consumer timeout after processing but before response
slow consumer causing producer retries
replay after dead-letter recoveryEvery item is ordinary production behavior. A receiver that handles only valid fresh messages is not finished.
Build a deterministic local harness
A small signing utility lets you replay exact bytes and mutate one variable at a time:
python tools/sign_webhook.py --secret whsec_test_7d29 --timestamp 1764523260 --body fixtures/invoice-paid.json --headerCapture real provider payloads in a safe test environment and strip sensitive data before committing fixtures. Store both the raw body and expected signature. Tests that reconstruct JSON differently from the fixture can pass while production byte verification fails.
Incident tooling should exist before the incident
You need operator commands for:
webhook-admin endpoint pause endp_42 --reason 'customer TLS certificate expired'
webhook-admin delivery redrive del_01J9RJD4 --limit 1
webhook-admin endpoint replay endp_42 --since '2026-11-30T16:00Z' --rate 20/s
webhook-admin events inspect evt_01J9RB5T --include-attemptsPause must stop new attempts without deleting history. Redrive must respect per-endpoint rate limits. Replay should ask whether ordering matters and should warn if events are old enough to confuse consumers. These are product features, not shell improvisations written while customers wait.
Reconciliation beats blind replay
After a long outage, blindly resending everything may be wrong. Offer a reconciliation path: list events by object, fetch current state, or request a bulk export. Consumers can compare the highest event ID or object version they processed with provider state. For ledger-like systems, event replay matters. For state-sync systems, current-state resynchronization may be safer.
Communicate in terms of delivery semantics
Customer communication should answer concrete questions: which endpoints, what time range, whether events were delayed or dropped, whether duplicates are expected, and what action customers should take. "We experienced elevated errors" is operationally empty. "Events between 16:05 and 17:40 UTC may be delayed or duplicated; dead-lettered deliveries will be replayed over two hours starting at 18:10 UTC" is actionable.
Field notes
- Keep failed response bodies for a short retention window; TLS errors and HTTP status alone often hide consumer-side deployment causes.
- During replay, dashboards must separate original attempts from manual redrives or you will misread recovery progress.
- Run a game day where a consumer endpoint is blackholed for thirty minutes and observe backlog shape, alerts, replay behavior, and data correctness.
- Do not test against customer production endpoints without approval; even signed test webhooks can mutate state if consumers ignore test mode.
- Incident closure should include durable fixes: retry policy, observability, validation, or documentation — not merely "queue drained.
Was this lesson helpful?