Skip to content

Conversation

@mattyb
Copy link
Member

@mattyb mattyb commented Oct 24, 2025

The retry_request function was repeatedly wrapping the wait strategy each time it was called with the same retrying object. Since APIClient reuses a single tenacity.Retrying instance across all API calls, this created deeply nested wait_for_retry_after_header wrappers. When the API returned an error without a Retry-After header, the fallback chain would recurse infinitely, exceeding Python's recursion limit.

The fix adds a guard to only wrap the wait strategy once, preserving the intended behavior: use Retry-After when present, otherwise fall back to the user's configured wait strategy (exponential backoff by default).

Added test that simulates 1000 consecutive API calls to verify the fix.

🤖 Generated with Claude Code


  • (For Civis employees only) Reference to a relevant ticket in the pull request title
  • Changelog entry added to CHANGELOG.md at the repo's root level
  • Description of change in the pull request description
  • If applicable, unit tests have been added and/or updated
  • The CircleCI builds have all passed

… is missing

The retry_request function was repeatedly wrapping the wait strategy
each time it was called with the same retrying object. Since APIClient
reuses a single tenacity.Retrying instance across all API calls, this
created deeply nested wait_for_retry_after_header wrappers. When the
API returned an error without a Retry-After header, the fallback chain
would recurse infinitely, exceeding Python's recursion limit.

The fix adds a guard to only wrap the wait strategy once, preserving
the intended behavior: use Retry-After when present, otherwise fall
back to the user's configured wait strategy (exponential backoff by
default).

Added test that simulates 1000 consecutive API calls to verify the fix.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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