diff --git a/doc/api/fundamentals.rst b/doc/api/fundamentals.rst index 9e8cd323bc..9e412f7454 100644 --- a/doc/api/fundamentals.rst +++ b/doc/api/fundamentals.rst @@ -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 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 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. +* 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. If you send a request with an ``X-Idempotency-Key`` header that we have seen before but that has not yet received a diff --git a/src/pretix/api/middleware.py b/src/pretix/api/middleware.py index 3ef08b2e9c..ba81e2a29f 100644 --- a/src/pretix/api/middleware.py +++ b/src/pretix/api/middleware.py @@ -72,7 +72,7 @@ class IdempotencyMiddleware: if created: resp = self.get_response(request) 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! call.delete() else: