aiohttp timeout and wrapped google-auth transport exceptions are not retried despite HttpRetryOptions being configured

Đang mở
#3,329 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Venkaiahbabuneelam đang làm issue này rồi.

Từ ngày 11/11/2026.

  • #3330 của @rladeira — đang mở
  • #3332 của @copybara-service — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, backend

Hướng nghiên cứu

Start in google/genai/_api_client.py at retry_args() and _AIOHTTP_TRANSIENT_EXC, then trace _async_request_once() to understand how authenticated transport exceptions are handled. Reproduce the listed predicates and add coverage for the timeout and wrapped transport cases, while checking that payload and refresh errors remain non-retryable and the no-retry_options path is unchanged.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

priority: p2 type: bug
Describe the bug

When HttpRetryOptions is configured and aiohttp is used as the async HTTP transport (google-genai[aiohttp]), request timeouts and wrapped google.auth.aio transport exceptions bypass retry_args() and fail on the first attempt without retrying.

Specifically:

  1. asyncio.TimeoutError (and aiohttp.ServerTimeoutError / aiohttp.ConnectionTimeoutError):
    While _HTTPX_TRANSIENT_EXC includes httpx.TimeoutException and httpx2.TimeoutException (added in #2345 for #2337), _AIOHTTP_TRANSIENT_EXC only lists (aiohttp.ClientConnectorError, aiohttp.ClientOSError, aiohttp.ServerDisconnectedError). In aiohttp, ClientTimeout(total=...) (TimerContext.__exit__) raises asyncio.TimeoutError directly, and aiohttp.ServerTimeoutError / ConnectionTimeoutError inherit from (aiohttp.ClientConnectionError, asyncio.TimeoutError), not ClientConnectorError, ClientOSError, or ServerDisconnectedError.
  2. google.auth.exceptions.TimeoutError (auth_exceptions.TimeoutError):
    When Vertex AI mTLS is used (_use_google_auth_async() == True), _get_aiohttp_session() returns google.auth.aio.transport.sessions.AsyncAuthorizedSession. Both google.auth.aio.transport.aiohttp.Request.__call__ and google.auth.aio.transport.sessions.timeout_guard catch asyncio.TimeoutError and raise google.auth.exceptions.TimeoutError (which inherits from GoogleAuthError, not builtins.TimeoutError or aiohttp.ClientError).
  3. google.auth.exceptions.TransportError wrapping _AIOHTTP_TRANSIENT_EXC:
    Under AsyncAuthorizedSession, google.auth.aio.transport.aiohttp.Request.__call__ catches aiohttp.ClientError and raises google.auth.exceptions.TransportError(...) from caught_exc. In _async_request_once(), the except (..., auth_exceptions.TransportError) block re-raises when retry_options is configured (raise # HttpRetryOptions owns retries; tenacity decides.), but retry_args() does not match auth_exceptions.TransportError wrapping _AIOHTTP_TRANSIENT_EXC.
Steps to reproduce
import asyncio
from google.auth import exceptions as auth_exceptions
from google.genai import _api_client as api_client
from google.genai import types
import aiohttp

retry = api_client.retry_args(types.HttpRetryOptions())['retry']
print("asyncio.TimeoutError retried:", retry.predicate(asyncio.TimeoutError()))
print("aiohttp.ServerTimeoutError retried:", retry.predicate(aiohttp.ServerTimeoutError()))
print("google.auth.exceptions.TimeoutError retried:", retry.predicate(auth_exceptions.TimeoutError("Request timed out")))

Output on main:

asyncio.TimeoutError retried: False
aiohttp.ServerTimeoutError retried: False
google.auth.exceptions.TimeoutError retried: False
Expected behavior

When HttpRetryOptions is configured, retry_args() should retry asyncio.TimeoutError (including aiohttp.ServerTimeoutError and aiohttp.ConnectionTimeoutError), google.auth.exceptions.TimeoutError, and google.auth.exceptions.TransportError whose __cause__ is in _AIOHTTP_TRANSIENT_EXC, matching the httpx.TimeoutException behavior from #2337 / #2345 while keeping non-transient errors (such as aiohttp.ClientPayloadError and google.auth.exceptions.RefreshError) and the no-retry_options path unchanged.

Ngôn ngữ chính
Python
Star
4.1k
Fork
1.1k
Merge trung bình
1 ngày 20 giờ
Pull request đã merge (30 ngày)
90

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của googleapis/python-genai

Tất cả issue của googleapis/python-genai

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.