After a small refactor, the invoice posting handler started behaving inconsistently on transaction errors and repeated requests. You need to review the diff and find the regressions.
POST /invoices/{id}/post accepts the Idempotency-Key header.{"amount": 1200}.200 and JSON {"invoiceId":"...","status":"posted","amount":1200}.Idempotency-Key and the same body must return the same saved response with status code 200 without changing state again.handler.go.Commit returns an error.Idempotency-Key;Idempotency-Key.500 and a response without any sign of successful posting.Idempotency-Key, the result must be determined atomically: a repeat must not start a second independent processing of the same invoice in parallel.1.24go test ./...MemoryStore must be safe for concurrent callsFakeTx transaction in test scenarios may return an error from Commit() without panicking and without additional side effectsUse line comments to explain the problem, its impact, the fix and how to test it.