rust.idempotency_key
Correctness
High
Detects non-idempotent operations without idempotency keys for safe retries.
Why It Matters
Section titled “Why It Matters”Missing idempotency keys:
- Duplicate processing — Retries create duplicates
- Data corruption — Multiple charges, orders
- Inconsistent state — Lost updates on retry
Example
Section titled “Example”// ❌ Before (no idempotency key)async fn create_payment(req: PaymentRequest) -> Payment { let payment = Payment::new(req.amount); db.insert(&payment).await?; payment}// ✅ After (with idempotency key)async fn create_payment( idempotency_key: &str, req: PaymentRequest) -> Result<Payment, Error> { // Check for existing payment with this key if let Some(existing) = db.find_by_idempotency_key(idempotency_key).await? { return Ok(existing); }
let payment = Payment::new(req.amount, idempotency_key); db.insert(&payment).await?; Ok(payment)}What Unfault Detects
Section titled “What Unfault Detects”- POST handlers without idempotency header
- Payment/order creation without dedup key
- State mutations without idempotency check
Auto-Fix
Section titled “Auto-Fix”Unfault can add idempotency key parameter and lookup logic.