Skip to content

fix: ignore non-finite Retry-After values - #260

Merged
luk384090-cloud merged 2 commits into
dashscope:mainfrom
hansu650:fix/nonfinite-retry-after
Dec 3, 2026
Merged

luk384090-cloud merged 2 commits into
dashscope:mainfrom
hansu650:fix/nonfinite-retry-after

Conversation

@hansu650

@hansu650 hansu650 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

A retryable response containing Retry-After: NaN currently produces a NaN backoff. Both time.sleep and asyncio.sleep reject it on Python 3.13, so the request stops with ValueError instead of retrying. The same issue affects retry-after-ms and the initial HTTP handshake for streaming requests.

Ignore non-finite numeric delays, including infinities and overflowed numeric strings. An invalid millisecond value falls back to a valid Retry-After value; otherwise the existing exponential backoff applies. Finite values keep their existing precedence, clamping and cap.

Validation in a dedicated Windows / Python 3.13.15 environment:

  • The 20 new non-finite-header regressions fail against the original implementation. A standalone reproduction also confirms both real sleep functions raise on NaN.
  • Transport, request options, SSE, error mapping and chat suites: 451 passed, including seven finite-value/date controls. Requests use httpx.MockTransport; no paid API calls were made.
  • Repository-pinned Black, Flake8 and Pylint checks for the changed files pass; mypy passes for the changed runtime module. git diff --check passes.
  • sdist/wheel build and Twine checks pass. Setuptools emits the existing license-classifier deprecation warning.

The full legacy/AgenticX suite and other Python/OS combinations were not run locally. Prepared with OpenAI Codex assistance, starting from source inspection rather than a reported production incident.

CI follow-up — 2026-12-03: the unit-test matrix and documentation build passed. The pre-commit run identified a missing trailing comma in one parametrized test signature. Applied the pinned add-trailing-comma hook followed by Black, verified both are now idempotent, and confirmed the file's Python AST is unchanged. Flake8/Pylint pass and all 113 transport tests pass. The runtime fix is unchanged; the updated remote checks are tracked separately.

@luk384090-cloud
luk384090-cloud merged commit b2be828 into dashscope:main Dec 3, 2026
10 checks passed
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.

2 participants