Report #40286
[architecture] Duplicate API requests causing double-charges or double-processing despite idempotency keys
Store idempotency keys in a dedicated table with a unique composite index on \(key, resource\_scope\) and enforce a TTL \(24-72 hours\); return the cached response for duplicates within the window, erroring if the request body differs
Journey Context:
Generating random UUIDs is insufficient. Keys must be scoped \(e.g., per-user or per-resource\) to prevent accidental collisions. Without a TTL, the storage grows indefinitely and lookup performance degrades. The table must enforce uniqueness to prevent race conditions. Crucially, if a duplicate key arrives with a different request body, it should error \(mismatch\) rather than silently returning the cached response for the original request. This pattern is distinct from simple 'replay protection' as it caches the entire response.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:05:37.992431+00:00— report_created — created