forked from CGM_Public/pretix_original
API: Allow retry with same idempotency token after error 500
This commit is contained in:
@@ -213,13 +213,16 @@ Please note that this also goes for most error responses. For example, if we ret
|
|||||||
error and you retry with the same ``X-Idempotency-Key``, you will get the same error again, even if you were granted
|
error and you retry with the same ``X-Idempotency-Key``, you will get the same error again, even if you were granted
|
||||||
permission in the meantime! This includes internal server errors on our side that might have been fixed in the meantime.
|
permission in the meantime! This includes internal server errors on our side that might have been fixed in the meantime.
|
||||||
|
|
||||||
There are only three exceptions to the rule:
|
There are only the following exceptions to the rule:
|
||||||
|
|
||||||
* Responses with status code ``409 Conflict`` are not cached. If you send the request again, it will be executed as a
|
* Responses with status code ``409 Conflict`` are not cached. If you send the request again, it will be executed as a
|
||||||
new request, since these responses are intended to be retried.
|
new request, since these responses are intended to be retried.
|
||||||
|
|
||||||
* Rate-limited responses with status code ``429 Too Many Requests`` are not cached and you can safely retry them.
|
* Rate-limited responses with status code ``429 Too Many Requests`` are not cached and you can safely retry them.
|
||||||
|
|
||||||
|
* Responses with status code ``500 Internal Server Error`` are not cached and you can retry them. This is not guaranteed
|
||||||
|
to be safe in all theoretical cases, but 500 by definition is an unforseen situation and we need to have some way out.
|
||||||
|
|
||||||
* Responses with status code ``503 Service Unavailable`` are not cached and you can safely retry them.
|
* Responses with status code ``503 Service Unavailable`` are not cached and you can safely retry them.
|
||||||
|
|
||||||
If you send a request with an ``X-Idempotency-Key`` header that we have seen before but that has not yet received a
|
If you send a request with an ``X-Idempotency-Key`` header that we have seen before but that has not yet received a
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class IdempotencyMiddleware:
|
|||||||
if created:
|
if created:
|
||||||
resp = self.get_response(request)
|
resp = self.get_response(request)
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
if resp.status_code in (409, 429, 503):
|
if resp.status_code in (409, 429, 500, 503):
|
||||||
# This is the exception: These calls are *meant* to be retried!
|
# This is the exception: These calls are *meant* to be retried!
|
||||||
call.delete()
|
call.delete()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user