Repository navigation
Fix: Honor Retry-After on 5xx responses, not just 429 - #616
Closed
ffumero2003 wants to merge 1 commit into
Closed
ffumero2003 wants to merge 1 commit into
ffumero2003 wants to merge 1 commit into
Conversation
A 5xx carrying Retry-After was ignored: the client retried on its default backoff instead of waiting the requested time, unlike 429. Give ServiceError a retry_after_seconds slot (mirroring TooManyRequests) and pass the header from the 5xx branch of interpret_b2_error; b2http already honors a non-None value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A
5xxcarryingRetry-After: Nis ignored — the client retries on its default backoff(~1s) instead of waiting N seconds, unlike
429which honors the header.Root cause
In
b2sdk/_internal/exception.py, the500 <= status < 600branch buildsServiceErrorfrom the message only and never reads
response_headers, andServiceErrorhad noretry_after_secondsslot (onlyTooManyRequestsdid).b2httpalready honors a non-Noneretry_after_secondson read — only the write side was missing.Fix
ServiceError__init__(self, *args, retry_after_seconds=None)that stores the value(mirrors
TooManyRequests).retry_after_seconds=response_headers.get('retry-after')from the 5xx branch.Verification
ServiceErrorfrom a 503 withRetry-After: 200hasretry_after_seconds == 200, andNonewithout it. Red before, green after; full unitsuite green across all apivers.
api.retry_after_503resilience failure (FAIL → PASS).Fixes #606