Skip to content

fix: honor HTTP-date Retry-After headers - #478

Draft
Kayvan-Zahiri wants to merge 1 commit into
replicate:mainfrom
Kayvan-Zahiri:codex/honor-http-date-retry-after
Draft

Kayvan-Zahiri wants to merge 1 commit into
replicate:mainfrom
Kayvan-Zahiri:codex/honor-http-date-retry-after

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Replicate's retry transport parses date-valued Retry-After headers with datetime.fromisoformat(). Valid HTTP-date values such as Sun, 18 Oct 2026 12:00:30 GMT fail parsing, so a response requesting a 30-second delay is retried after the default 0.1-second backoff.

Add HTTP-date parsing using the standard library, treating timezone-free obsolete HTTP-date forms as UTC. Preserve existing ISO date compatibility, numeric delays, date delay cap, and fallback behavior for expired/malformed values. Both synchronous and asynchronous requests use the same helper.

Validation:

  • 44 new controlled HTTPX sync/async retry cases cover 429/503, all three HTTP-date forms, capped future dates, expired dates, numeric values, ISO compatibility, and malformed/empty values. Before: 16 fail, 28 pass. After: all pass.
  • Full repository test script with --record-mode=none: 202 passed, 6 skipped; no live predictions or API requests.
  • Repository lint script passes: Pyright 0 errors, Ruff lint and formatting pass. Pylint is advisory (--exit-zero) and reports existing unrelated warnings; no warnings on the added parsing code.
  • Wheel/sdist build and diff check pass.

HTTP-date contract: https://www.rfc-editor.org/rfc/rfc9110.html#name-retry-after

Signed-off-by: Kayvan Zahiri <kzahiri@dons.usfca.edu>
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.

1 participant