Retry-After from the server is used without a limit

Open Beginner friendly
#23 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start with OpenAIClient._request_with_retry in src/chatty/client/openai_client.py, especially the Retry-After handling around line 259; read the surrounding retry logic and tests for 429 and 5xx responses. Check how delay values such as negative, inf, and nan are handled, then run the relevant tests. Done means waits are bounded and an over-limit server delay produces a useful retry-time message rather than leaving the user waiting.

Written by the indexing model from the issue text.

Description

area: client bug

OpenAIClient._request_with_retry (src/chatty/client/openai_client.py:203) uses the server's Retry-After header as the wait before retrying a 429 or 5xx response, with no upper limit (line 259, wait_time = float(retry_after)).

Effect:

  • Retry-After: 3600 makes chatty wait an hour, twice (MAX_RETRIES = 2), with the status bar still showing "Thinking...". Esc cancels it, but nothing tells the user why it's stuck.
  • Retry-After: inf (accepted by float()) sleeps forever, and Retry-After: nan raises ValueError: Invalid delay: NaN from asyncio.sleep, which reaches the user as "Unexpected error".
  • A negative value is passed through to asyncio.sleep, which then doesn't wait at all.

Fix: clamp the wait to a finite range (for example 0 to 60 seconds). If the server asks for longer, fail now with a message that says when to retry, instead of waiting.

Dominant language
Python
Stars
0
Forks
2
Avg merge
1d 4h
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanl/chatty

All issues in lanl/chatty

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.