Skip to content

Fix 'max_retries' request argument crashing the request - #357

Merged
iLLiCiTiT merged 2 commits into
developfrom
bugfix/request-max-retries-kwarg
Sep 14, 2026
Merged

iLLiCiTiT merged 2 commits into
developfrom
bugfix/request-max-retries-kwarg

Conversation

@BigRoy

@BigRoy BigRoy commented Sep 12, 2026

Copy link
Copy Markdown
Member

Bug

Passing max_retries to a raw request crashes:

>>> con.raw_get("projects", max_retries=2)
TypeError: Session.request() got an unexpected keyword argument 'max_retries'

Cause

_do_rest_request reads the per-request override with kwargs.get("max_retries", ...) but leaves it in kwargs, which are then passed to requests / requests.Session functions that don't accept it.

Fix

kwargs.pop("max_retries", None) and fall back to the connection's max_retries.

Reproduce

import ayon_api
con = ayon_api.get_server_api_connection()
print(con.raw_get("projects", max_retries=2).status)
# develop: TypeError
# this PR: 200

Testing notes

  • Run the snippet above, with and without a session (ServerAPI(..., create_session=False) uses requests.get directly — same error on develop).
  • tests/test_request_max_retries_kwarg.py checks the argument is not passed and the given number of attempts is used.

🤖 Generated with Claude Code

'_do_rest_request' read 'max_retries' from kwargs but did not remove it,
so it was passed to the requests function, which raised TypeError
(e.g. 'raw_get("projects", max_retries=2)'). Pop the argument instead.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread ayon_api/server_api.py Outdated
@BigRoy
BigRoy requested a review from iLLiCiTiT September 13, 2026 20:12
@BigRoy BigRoy added the type: bug Something isn't working label Sep 13, 2026
@BigRoy
BigRoy requested a lite review from Copilot September 13, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fix is covered by regression tests and no unresolved blocking issues were identified.

Pull request overview

Fixes max_retries request handling so it is not forwarded to requests, preventing raw request crashes.

Changes:

  • Removes the per-request max_retries argument before forwarding kwargs.
  • Preserves connection-level retry defaults.
  • Adds regression tests for retry behavior.
File summaries
File Description
tests/test_request_max_retries_kwarg.py Verifies argument handling and retry counts.
ayon_api/server_api.py Corrects per-request retry override handling.
Review details
  • Files reviewed: 2/2 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.

@BigRoy
BigRoy marked this pull request as ready for review September 14, 2026 08:24
Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
@iLLiCiTiT
iLLiCiTiT merged commit 8ce5db9 into develop Sep 14, 2026
3 checks passed
@iLLiCiTiT
iLLiCiTiT deleted the bugfix/request-max-retries-kwarg branch September 14, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants