Test duplicate webhook deliveries
This fixed authored exercise uses Python 3 and its standard-library SQLite module. No Gostly installation, account, provider connection or HTTP receiver is needed. It creates temporary databases, interrupts only its owned child processes, reopens their databases and removes the temporary directory after checking the records.
The logical key is source + account + event_id. Delivery attempts have separate IDs; different legitimate events can concern the same resource. Source/account labels here are synthetic fixture scope, not authenticated provider claims. In a real handler derive that scope from trusted producer or authentication context.
Run the correct key and the two wrong controls
The packet uses the Python standard library and a local SQLite inbox/outbox-intent transaction. Event evt_A requests +3 units and evt_B requests +2 for the same item; A is delivered again with another attempt ID. The same textual event ID under another source or account has its own +3 intent.
Its closed version-1 inventory.adjusted body compares every accepted field, including event ID, resource ID and integer delta_units. Parsed property order and whitespace are irrelevant; invalid/unknown fields are refused. Changed semantic content under the same logical key is a conflict that preserves the original accepted intent.
Save the script and instructions in the same working folder, then run:
python3 exercise.pyRead the ledger expectations alongside the output. The expected local packet totals are +5 intended units for the correct key, +8 for the attempt-ID key and +3 for the resource-ID key in the first source/account/item scope. A successful run requires the same oracle to accept the first and reject both wrong controls. These totals project stored intents, not external inventory changes. Restart cases reopen the SQLite file around the commit/acknowledgement boundary.
The checked result is an outbox intent. The exercise does not execute provider delivery, HTTP handling, signature verification, authentication or external dispatch. A local intent count is not an exactly-once guarantee for a payment, email or inventory change. The transactional outbox pattern separates a committed record from later dispatch.
Require the controls to distinguish the failure
| Case | Required local result | What it rejects |
|---|---|---|
| Same event, new delivery attempt | One inbox identity and one adjustment intent for that event. | A delivery-attempt key that records the adjustment twice. |
| Different event, same inventory item | Both legitimate events retain their own intents. | An item/resource key that drops the later adjustment. |
| Same event ID, different source or account | Each distinct source/account scope remains eligible. | A global event-ID key that merges independent events. |
| Reordered JSON or changed content | Equivalent content is a duplicate; changed content under the same key follows the explicit conflict policy. | Treating every byte change as new work, or overwriting a conflicting event silently. |
| Unknown or invalid event fields | Refuse the closed-schema negative inputs before acceptance. | Silently dropping unknown fields or accepting a boolean as an integer adjustment. |
| Exit after inbox insert, before outbox/commit | No committed inbox or intent; reopening and retrying can record the event. | A remembered receipt without its matching intended action. |
| Commit returns, then exit before acknowledgement | Reopen the database and retry without recording a second intent. | Inferring that a missing acknowledgement means the transaction did not commit. |
Inspect what was committed, not just what the handler returned. A client can lose an acknowledgement after a transaction commits; repeating that event must consult the persisted identity and recorded intent.
Read the output and restart checks
A successful command exits 0 after naming the correct key, both rejected wrong-key controls, semantic-conflict/reordered-JSON checks, closed-schema controls and both restart points, followed by PASS local inbox/outbox-intent exercise. Any unexpected condition exits nonzero. The script reports Python/SQLite versions and effective rollback-journal settings; retain those with the output.
- Before commit: the child exits after inbox insert but before the outbox write. Reopening must find neither committed record. Retrying stores one pair; another repeat is a duplicate.
- After commit, before acknowledgement: the child exits only after commit returns successfully. Reopening must find both records. Retrying preserves the one original intent.
If commit fails or never returns, its outcome is unknown: reopen and resolve acceptance through the logical key. These sequential local process interruptions do not certify power-loss survival, concurrency, every filesystem, HTTP acknowledgements or downstream dispatch.
Add HTTP replay when your test needs it
The download is not an HTTP receiver. Provide a safe test endpoint before adding Gostly. Use the supported Pro HTTP setup, then follow manual replay for a selected UTF-8 capture and approved, API-reachable target. Check the capture, retained record, target response and durable consumer result separately.
A Gostly capture ID identifies the retained delivery record, not the consumer’s logical event. Replaying the same stored capture can reuse that ID; your driver owns separate attempt identity. Capture/replay does not add this consumer transaction, provider signature verification, logical deduplication or external exactly-once effects. Follow the identity and effect-boundary guide to adapt the policy.