Skip to content

fix(retry): retry google-auth TransportError with HttpRetryOptions - #2870

Open
emileferreira wants to merge 1 commit into
googleapis:mainfrom
emileferreira:fix/retry-google-auth-transport-error
Open

fix(retry): retry google-auth TransportError with HttpRetryOptions#2870
emileferreira wants to merge 1 commit into
googleapis:mainfrom
emileferreira:fix/retry-google-auth-transport-error

Conversation

@emileferreira

Copy link
Copy Markdown

Fixes #2869

Summary

  • retry google.auth.exceptions.TransportError when HttpRetryOptions is enabled
  • keep permanent authentication failures such as RefreshError non-retryable
  • add an async regression test proving credential refresh can recover before
    dispatching exactly one model HTTP request

Google Auth wraps token-endpoint connection failures as TransportError, so
they bypass the existing HTTPX exception branch in retry_args(). Credential
acquisition occurs inside _async_request_once() and before model dispatch,
which means the existing Tenacity boundary can safely retry this failure.

This follows the precedent established by #2337 and #2345 for lower-level
HTTPX transport errors. It also matches the retry predicates used by other
Google Python clients such as Cloud Storage and BigQuery.

Retries remain opt-in through HttpRetryOptions. This change does not retry
RefreshError, invalid grants, missing credentials, or other permanent
authentication failures.

Testing

  • pytest google/genai/tests/client/test_retries.py::test_retry_args_retries_transport_errors google/genai/tests/client/test_retries.py::test_async_retries_google_auth_transport_error -q
    • 2 passed
  • mypy google/genai/
    • success
  • git diff --check
    • success

Scope note

The aiohttp branches already perform one hard-coded retry for
TransportError. This PR leaves that existing no-options behaviour unchanged;
consolidating the aiohttp retry path would be a separate behavioural change.

@google-cla

google-cla Bot commented Aug 17, 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 Aug 18, 2026
@Venkaiahbabuneelam Venkaiahbabuneelam added the size:L Code changes between 40-100 lines label Aug 18, 2026
@Venkaiahbabuneelam

Copy link
Copy Markdown

Hi @emileferreira, Thanks for reaching out us!

Please resolve all conflict checks.
Thanks

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

Labels

size:L Code changes between 40-100 lines status:awaiting user response

Projects

None yet

Development

Successfully merging this pull request may close these issues.

google.auth.exceptions.TransportError is not retried despite HttpRetryOptions

2 participants