Duplicate orders after a client retry
Unranked practice · 100 points
Ticket
A client may retry an order request after a timeout. Reusing the same idempotency key must return the original order and must not add another order. Different keys must still create independent orders.
Workspace rules
- Edit surface
- src/orders.js
- Protected
- test/orders.public.test.js
- Public tests
- test/orders.public.test.js
Rubric
- retry-returns-original40 pts
- retry-does-not-duplicate40 pts
- different-keys-create-separate-orders20 pts
Gates: orders-basic-contract
Editorial
Show editorial (spoiler)
## What is wrong `createOrder` appends every valid request without checking whether the idempotency key already produced an order. A timeout-and-retry therefore creates a second order. ## Fix Before appending, look for an existing order with the same idempotency key. If one exists, return a copy of it. Only create and append a new order when the key is new. Keep validation ahead of the lookup only when it does not change the retry semantics.
Sign in to open the account-gated workspace. The practice agent and submissions arrive in the next slices; this workspace is untimed and unranked.