Repository navigation
Conversation
The retry counter in the client's pagination loops was reset at the start of every pass of `while next_url:`, so a provider that kept returning 429 Too Many Requests was retried forever and `max_attempts` was never reached. Initialise the counter once before the loop and reset it only after a page succeeds, in both the sync and async paths. Add sync and async tests with an HTTP client that always returns 429. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anikeya9
requested review from
CasperWA,
ml-evs,
ndaelman-hu and
rartino
as code owners
November 12, 2026 12:57
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2459 +/- ##
==========================================
+ Coverage 90.37% 90.71% +0.33%
==========================================
Files 78 78
Lines 5122 5124 +2
==========================================
+ Hits 4629 4648 +19
+ Misses 493 476 -17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2458
The retry counter in the client's pagination loops was reset at the start of every pass of
while next_url:, including the pass that follows a retry. As a result, a provider that keeps returning429 Too Many Requestswas retried forever andmax_attemptswas never reached (see the issue for a reproduction).Changes
optimade/client/client.py: in both_get_one_asyncand_get_one,attemptsis now initialised once before the loop and reset only after a page has been fetched successfully, so each page keeps its own retry budget ofmax_attempts.tests/server/test_client.py: newtest_retry_limit_asyncandtest_retry_limit_sync, using test HTTP clients that always return 429 (with the wait between retries patched out). They check that exactlymax_attempts + 1requests are made and that the "Exceeded maximum number of retries" error is reported for the provider. Without the fix, both tests fail (the test clients stop the loop after 50 requests instead of hanging).Note
Retries still count towards
number_of_requests, and therefore towards themax_requests_per_providerguard rail. I left this unchanged to keep the PR minimal, but I'm happy to change it if you prefer.🤖 Generated with Claude Code