TEST REPORT: Webhooks Done Right (for Stripe) v1.1.0
Run from a clean unzipped copy of the v1.1.0 dist zip (fresh npm ci / pip install). Started 2026-10-22 18:13:19 BST (UTC+01:00), finished 2026-10-22 18:13:35 BST (UTC+01:00) (times from date at run time). Box: Linux 6.12, Node v24.22.0, Python 3.13.5, PostgreSQL 17.11 (Debian package, local). Libraries: stripe-node 19.3.0, express 4.22.3, pg 8.23.1; stripe-python 16.0.0, Flask 3.1.3, psycopg 3.3.6, psycopg-pool 3.3.3, pytest 9.1.1.
Result: 36/36 passed with Postgres (Node 18/18 + Python 18/18). The TypeScript typecheck is clean. Without DATABASE_URL the Postgres tests are skipped, not failed: Node 13 passed + 5 skipped, Python 13 passed + 1 skipped module (its 5 tests). templates/schema.sql was also applied twice with psql (both exit 0).
Scope: the tests cover rules 1 to 7 in SKILL.md: - Rules 1 to 5 (raw body, correct secret, replay window, idempotency, status codes), as in v1.0. - Rule 4 (idempotency) now also runs against real Postgres. - Rule 6 (acknowledge before slow work) and rule 7 (out-of-order events, re-fetch) are new.
Rules 8 and 9 (fulfilment events, API version) are guidance and are not covered by tests.
Method: fixtures are signed locally. Node uses stripe-node's generateTestHeaderString; Python uses tests/signing.py, which follows Stripe's documented HMAC scheme. The real Stripe libraries then check the signatures. No live Stripe deliveries were used. Each Postgres test run creates its own throwaway schema in a scratch database and drops it afterwards (0 left over after this run).
The zip that was tested differs from the shipped zip only in this file (TEST-REPORT.md), which was written after the run.
Postgres: templates/schema.sql applied with psql (twice, to check it is re-runnable)
Command: PGOPTIONS='-c search_path=skh_schema_check' psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f templates/schema.sql (run twice), then \d stripe_events. Local paths in the output are shortened.
NOTICE: schema "skh_schema_check" does not exist, skipping
DROP SCHEMA
CREATE SCHEMA
CREATE TABLE
schema.sql run 1 exit 0
psql:templates/schema.sql:8: NOTICE: relation "stripe_events" already exists, skipping
CREATE TABLE
schema.sql run 2 exit 0
Table "skh_schema_check.stripe_events"
Column | Type | Collation | Nullable | Default
--------------+--------------------------+-----------+----------+---------
id | text | | not null |
type | text | | not null |
status | text | | not null |
received_at | timestamp with time zone | | not null | now()
processed_at | timestamp with time zone | | |
Indexes:
"stripe_events_pkey" PRIMARY KEY, btree (id)
Check constraints:
"stripe_events_status_check" CHECK (status = ANY (ARRAY['processing'::text, 'processed'::text]))
NOTICE: drop cascades to table skh_schema_check.stripe_events
DROP SCHEMA
leftover test schemas: 0
Node, with Postgres: cd node && npm ci && DATABASE_URL=postgres://…/scratch npm test
✔ postgres: templates/schema.sql applies cleanly, twice (idempotent) (24.79132ms)
✔ postgres: duplicate delivery of same event id is processed once (30.091724ms)
✔ postgres: concurrent duplicate deliveries are processed once (66.358256ms)
✔ postgres: two app instances (separate pools) sharing one database process a concurrent duplicate once (62.309205ms)
✔ postgres: handler failure -> 500, claim released, retry succeeds (12.602846ms)
✔ rule 6: slow work is queued, 200 is returned before it finishes, and runs once (1524.846356ms)
✔ rule 7: out-of-order delivery (older payment_failed after succeeded) keeps the current state via re-fetch (8.600414ms)
✔ valid signature -> 200 and handler runs once (19.794486ms)
✔ wrong secret -> 400, handler not called (3.96434ms)
✔ tampered body -> 400 (2.22735ms)
✔ re-serialised JSON (key order/whitespace changed) -> 400: raw body matters (2.427133ms)
✔ stale timestamp (older than 300s tolerance) -> 400 replay protection (2.339406ms)
✔ missing header -> 400 (2.022402ms)
✔ duplicate delivery of same event id is processed once (5.309468ms)
✔ concurrent duplicate deliveries are processed once (24.045349ms)
✔ handler failure -> 500, claim released, retry succeeds (3.470299ms)
✔ unhandled event type -> 200 handled:false (do not make Stripe retry) (1.884041ms)
✔ misconfigured app (express.json before router) is detected -> 500 (7.326235ms)
ℹ tests 18
ℹ pass 18
ℹ fail 0
ℹ skipped 0
typecheck: OK
Node, without Postgres: npm test (no DATABASE_URL)
﹣ postgres: templates/schema.sql applies cleanly, twice (idempotent) (0.439314ms) # DATABASE_URL not set (Postgres tests skipped)
﹣ postgres: duplicate delivery of same event id is processed once (0.10331ms) # DATABASE_URL not set (Postgres tests skipped)
﹣ postgres: concurrent duplicate deliveries are processed once (0.078989ms) # DATABASE_URL not set (Postgres tests skipped)
﹣ postgres: two app instances (separate pools) sharing one database process a concurrent duplicate once (0.083143ms) # DATABASE_URL not set (Postgres tests skipped)
﹣ postgres: handler failure -> 500, claim released, retry succeeds (2.725609ms) # DATABASE_URL not set (Postgres tests skipped)
✔ rule 6: slow work is queued, 200 is returned before it finishes, and runs once (1525.250212ms)
✔ rule 7: out-of-order delivery (older payment_failed after succeeded) keeps the current state via re-fetch (8.411197ms)
✔ valid signature -> 200 and handler runs once (31.463832ms)
✔ wrong secret -> 400, handler not called (4.466091ms)
✔ tampered body -> 400 (2.591255ms)
✔ re-serialised JSON (key order/whitespace changed) -> 400: raw body matters (2.358023ms)
✔ stale timestamp (older than 300s tolerance) -> 400 replay protection (2.65466ms)
✔ missing header -> 400 (2.039092ms)
✔ duplicate delivery of same event id is processed once (5.530441ms)
✔ concurrent duplicate deliveries are processed once (23.855465ms)
✔ handler failure -> 500, claim released, retry succeeds (3.821373ms)
✔ unhandled event type -> 200 handled:false (do not make Stripe retry) (1.828603ms)
✔ misconfigured app (express.json before router) is detected -> 500 (9.382788ms)
ℹ tests 18
ℹ pass 13
ℹ fail 0
ℹ skipped 5
Python, SQLite only: pip install -r requirements.txt && python -m pytest -v tests (no DATABASE_URL, psycopg not installed)
collecting ... collected 13 items / 1 skipped
tests/test_rules_6_7.py::test_rule6_slow_work_queued_ack_before_it_finishes PASSED [ 7%]
tests/test_rules_6_7.py::test_rule7_out_of_order_delivery_refetch_keeps_current_state PASSED [ 15%]
tests/test_webhook.py::test_valid_signature PASSED [ 23%]
tests/test_webhook.py::test_wrong_secret PASSED [ 30%]
tests/test_webhook.py::test_tampered_body PASSED [ 38%]
tests/test_webhook.py::test_reserialised_json_fails PASSED [ 46%]
tests/test_webhook.py::test_stale_timestamp PASSED [ 53%]
tests/test_webhook.py::test_missing_header PASSED [ 61%]
tests/test_webhook.py::test_duplicates_processed_once PASSED [ 69%]
tests/test_webhook.py::test_concurrent_duplicates_processed_once PASSED [ 76%]
tests/test_webhook.py::test_handler_failure_then_retry PASSED [ 84%]
tests/test_webhook.py::test_unhandled_type_acknowledged PASSED [ 92%]
tests/test_webhook.py::test_zero_tolerance_rejected PASSED [100%]
======================== 13 passed, 1 skipped in 1.72s =========================
Python, with Postgres: pip install -r requirements-postgres.txt && DATABASE_URL=postgres://…/scratch python -m pytest -v tests
collecting ... collected 18 items
tests/test_postgres.py::test_pg_schema_sql_applies_twice PASSED [ 5%]
tests/test_postgres.py::test_pg_duplicates_processed_once PASSED [ 11%]
tests/test_postgres.py::test_pg_concurrent_duplicates_processed_once PASSED [ 16%]
tests/test_postgres.py::test_pg_two_app_instances_share_one_db PASSED [ 22%]
tests/test_postgres.py::test_pg_handler_failure_then_retry PASSED [ 27%]
tests/test_rules_6_7.py::test_rule6_slow_work_queued_ack_before_it_finishes PASSED [ 33%]
tests/test_rules_6_7.py::test_rule7_out_of_order_delivery_refetch_keeps_current_state PASSED [ 38%]
tests/test_webhook.py::test_valid_signature PASSED [ 44%]
tests/test_webhook.py::test_wrong_secret PASSED [ 50%]
tests/test_webhook.py::test_tampered_body PASSED [ 55%]
tests/test_webhook.py::test_reserialised_json_fails PASSED [ 61%]
tests/test_webhook.py::test_stale_timestamp PASSED [ 66%]
tests/test_webhook.py::test_missing_header PASSED [ 72%]
tests/test_webhook.py::test_duplicates_processed_once PASSED [ 77%]
tests/test_webhook.py::test_concurrent_duplicates_processed_once PASSED [ 83%]
tests/test_webhook.py::test_handler_failure_then_retry PASSED [ 88%]
tests/test_webhook.py::test_unhandled_type_acknowledged PASSED [ 94%]
tests/test_webhook.py::test_zero_tolerance_rejected PASSED [100%]
============================== 18 passed in 1.96s ==============================
What the new tests check
- Postgres (5 per language):
schema.sqlapplies twice, has the expected columns, and rejects a badstatus.- 3 sequential duplicates are processed once, with the row
processedandprocessed_atset. - 8 concurrent duplicates are processed once.
- 8 concurrent duplicates spread over two app instances with separate connection pools sharing one database are processed once.
- A handler failure returns 500 and releases the claim, and the retry succeeds.
- Sanity check during development (not part of the suite): swapping the atomic
INSERT … ON CONFLICT DO NOTHINGclaim for a check-then-insert made both concurrency tests fail in both languages. - Rule 6:
- The handler only enqueues a job that takes 1.5 s, and the endpoint must answer 200 in under 0.5 s, before the job finishes. A duplicate delivery adds no second job.
- The queue is the bundled in-memory
InMemoryJobQueue; a durable queue is not tested. - Rule 7:
payment_intent.succeededarrives first, then the olderpayment_intent.payment_failedarrives late. The re-fetch handler keepssucceeded.- A control handler that trusts the payload ends on the wrong state (
requires_payment_method), which shows the test can catch the bug. - The Stripe API
retrievecall is a local stub (mocked), not a real API call.
Not tested
- Live deliveries from Stripe and the Stripe CLI (both need a Stripe account).
- Rule 7's re-fetch calls a stubbed
retrieve; it has not been run against the real Stripe API. - Rule 6 uses an in-process queue; durable queues (jobs table, BullMQ, Celery, SQS) are not included or tested.
- Rules 8 and 9 (fulfilment events, API version) are guidance and are not covered by tests.
- Postgres versions other than 17, and managed Postgres services.
- The Dashboard steps (Workbench > Webhooks, Snapshot payload) were written from Stripe's docs, not clicked through.
Agent dry-run
This was a self-review by the builder, not an independent agent run. The description names concrete triggers, and every file the steps refer to exists.