Skip to content

fix: Honor Retry-After on 5xx responses, not just 429 (#606) - #609

Closed
ffumero2003 wants to merge 1 commit into
masterfrom
codex/fix-606-retry-after-5xx
Closed

ffumero2003 wants to merge 1 commit into
masterfrom
codex/fix-606-retry-after-5xx

Conversation

@ffumero2003

Copy link
Copy Markdown
Contributor

Problem

A 429 with Retry-After: 2 makes the client wait ~2s, but a 503 (or any 5xx)
with the same header waits only its default backoff — the header is ignored.

Root cause

interpret_b2_error's 5xx branch builds ServiceError('%d %s %s'...) from the
message only and never reads response_headers['retry-after']. ServiceError
had no __init__, so it inherited B2Error's unconditional
retry_after_seconds = None. b2http's retry loop then always falls back to
default backoff for 5xx. (429 works because TooManyRequests stores the header.)

Fix

Mirror TooManyRequests: give ServiceError an __init__ that accepts and
stores retry_after_seconds, and pass response_headers.get('retry-after')
through in the 5xx branch. The read side (b2http._translate_and_retry) already
honors a non-None value, so no change there.

Testing

  • New unit tests: 503 with a Retry-After header stores it; without one it stays
    None (red before, green after), mirroring the existing 429 tests.
  • Full unit suite green across all API versions (nox -s unit, apiver v0–v3).

Fixes #606.

@ffumero2003 ffumero2003 changed the title Honor Retry-After on 5xx responses, not just 429 fix: Honor Retry-After on 5xx responses, not just 429 (#606) Sep 28, 2026

@sophiecarreras sophiecarreras left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is superseded by #619, which carries the same code and tests (only the changelog sentence differs). Closing this one avoids two PRs adding the same fragment and test. Please close whichever you want to drop; I suggest keeping #619.

@ffumero2003

Copy link
Copy Markdown
Contributor Author

Superseded by #619, which merged to master with the same fix plus the review nits. The change here is already on master, so closing this duplicate.

@ffumero2003 ffumero2003 closed this Oct 1, 2026
@ffumero2003
ffumero2003 deleted the codex/fix-606-retry-after-5xx branch October 1, 2026 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Retry-After is honored on 429 but structurally cannot be read on any 5xx response

2 participants