Fix successful request retry returning previous failure - #356
Draft
BigRoy wants to merge 2 commits into
Draft
Conversation
'_do_rest_request' stored the error response of a failed attempt (connection error, timeout, 502, 503) and never cleared it. After the retry loop the stored failure was returned even when a later attempt succeeded. Reset it at the start of each attempt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
iLLiCiTiT
reviewed
Sep 14, 2026
Comment on lines
+1563
to
1567
| # Reset failure of previous attempt, otherwise a successful | ||
| # retry would return the previous failure | ||
| new_response = None | ||
| try: | ||
| response = function(url, **kwargs) |
Member
There was a problem hiding this comment.
Suggested change
| # Reset failure of previous attempt, otherwise a successful | |
| # retry would return the previous failure | |
| new_response = None | |
| try: | |
| response = function(url, **kwargs) | |
| try: | |
| response = function(url, **kwargs) | |
| new_response = None |
Member
There was a problem hiding this comment.
I would reuse the last captured error, but we should reset it after successfull attempt. (this is big one)
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues were identified.
Pull request overview
Fixes request retries so a later successful attempt is returned instead of an earlier failure.
Changes:
- Clears stale failure state before each retry.
- Adds regression tests for connection errors and HTTP 503 responses.
- Adds a reusable fake response helper.
File summaries
| File | Description |
|---|---|
tests/test_request_retries.py |
Verifies successful retries return successful responses. |
tests/fake_transfer.py |
Provides a minimal response test double. |
ayon_api/server_api.py |
Resets retry failure state before each attempt. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Bug
Retries of REST requests can't succeed. If an attempt fails (connection error, timeout,
502,503) and a later retry succeeds,_do_rest_requeststill returns the first failure.This affects every
get/post/put/... call and GraphQl queries, e.g. while the server is restarting or behind a flaky proxy.Cause
The failure of an attempt is stored in
new_response. It was never cleared, and after the retry loop:so the successful
responsefrom a later attempt was ignored.Fix
Reset
new_response = Noneat the start of each attempt, so only a failure of the last attempt is returned.Reproduce
Needs an attempt to fail and the next one to succeed, so the easiest way is with a patched request function:
Testing notes
tests/test_request_retries.pycovers a connection error and a503followed by success.con.get("info"); requests that succeed on a retry now return data instead of an error.🤖 Generated with Claude Code