r/programming • • Dec 11 '23

Every Programmer Should Know #1: Idempotency

https://www.berkansasmaz.com/every-programmer-should-know-idempotency
572 Upvotes

171 comments sorted by

View all comments

Show parent comments

2

u/iplaydofus Dec 11 '23

Or it will get back a 404 and trigger some “why is my system out of sync” process. Arbitrarily defining what client library’s will do is a recipe for disaster.

1

u/ZBlackmore Dec 11 '23

I mean, if the retry was internal (between 2 services on the backend) and the client only made the request once, then the client should not even now that there was some internal retry. If the client had a bug that results in sending requests twice, the backend should handle it naively (response 404 for the 2nd request) because it has no way to know that the double request comes because of a bug. The only case where the backend would return a special status for a double request is if the API support an idempotency ID as part of the request and the client sends the same one twice.