Skip to content

fix(interactions): map HttpRetryOptions.attempts onto the retry count - #3261

Open
Vivek1898 wants to merge 1 commit into
googleapis:mainfrom
Vivek1898:fix/3260-interactions-retry-attempts
Open

Vivek1898 wants to merge 1 commit into
googleapis:mainfrom
Vivek1898:fix/3260-interactions-retry-attempts

Conversation

@Vivek1898

Copy link
Copy Markdown

Fixes #3260.

HttpRetryOptions.attempts counts the original request, so 0 and 1 both mean no retries. For the Interactions API, _translate_retry_config passed that number straight through as max_retries, which counts retries, so attempts=1 sent the request twice. attempts=0 behaved the same way because retry_args in the parent client rewrites 0 to 1 before the Interactions client is built. In both cases the second request waited for the full Retry-After, which on a free-tier daily quota means blocking for hours instead of failing at once.

The translation now maps attempts to attempts - 1, floored at zero. The default when attempts is unset is unchanged.

Tests in tests/interactions/test_retry_options.py:

  • the mapping for unset, 0, 1, 2 and 5 attempts;
  • attempts=0 and attempts=1 send exactly one request on a 429 and raise RateLimitError;
  • attempts=3 sends up to three requests and succeeds when the third one does.

@google-cla

google-cla Bot commented Nov 4, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Venkaiahbabuneelam Venkaiahbabuneelam self-assigned this Nov 4, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:XL Code changes > 100 lines label Nov 4, 2026
@Venkaiahbabuneelam

Copy link
Copy Markdown

Hi @Vivek1898, Thanks for reaching out us!

Please resolve the conflicts.

Thanks

@Vivek1898

Copy link
Copy Markdown
Author

Thanks. Rebased onto main at 1671a3f; the branch merges cleanly now, and the new test picks the HTTP client backend the same way test_auth.py does after the httpx2 switch. The remaining red check is the CLA.

@Vivek1898

Copy link
Copy Markdown
Author

The CLA is signed now; please re-run the check.

`attempts` counts the original request, so 0 and 1 both mean no retries.
`_translate_retry_config` passed it straight through as `max_retries`,
which counts retries, so attempts=1 retried once. attempts=0 is rewritten
to 1 by `retry_args` in the parent client before the Interactions client
is built, so it retried once as well, sleeping for the full Retry-After
before the second request.

Map attempts to attempts - 1, floored at zero. The default when attempts
is unset does not change.

Fixes googleapis#3260
@Vivek1898
Vivek1898 force-pushed the fix/3260-interactions-retry-attempts branch from 1671a3f to 10fdcce Compare November 4, 2026 06:55
@Vivek1898

Copy link
Copy Markdown
Author

Superseded by 0f688a6 on main (Mark Daoust, "fix(interactions): retries = attempts - 1"), which fixes #3260 and handles it better than this PR: it maps attempts to max(attempts - 1, 0) so 0 and 1 both mean no retries, and unifies the unset default with _api_client._RETRY_ATTEMPTS instead of a local constant. Closing this as no longer needed. Thanks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to completely disable API retries for interactions API

2 participants