[Fixes] Aiohttp transport fixes - add handling for aiohttp.ClientPayloadError and ssl_verification settings - #11162
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Aiohttp transport by adding explicit handling for aiohttp.ClientPayloadError, ensures ssl_verify defaults to True when unset, and standardizes date formats in a backup JSON.
- Gracefully continue streaming on incomplete payload errors in
AiohttpResponseStream. - Default
ssl_verifytoTruein transport builders and update test expectations. - Normalize
deprecation_datetoYYYY-MM-DDform in the backup JSON.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| tests/local_testing/test_ollama.py | Added assertions and debug prints to verify SSL settings in the new Aiohttp transport |
| litellm/model_prices_and_context_window_backup.json | Updated deprecation_date entries to zero-padded YYYY-MM-DD format |
| litellm/llms/custom_httpx/http_handler.py | Set ssl_verify=True when None and streamline verify_ssl assignment |
| litellm/llms/custom_httpx/aiohttp_transport.py | Expanded AIOHTTP_EXC_MAP, added handling for ClientPayloadError, and removed external import |
| print("type of transport in client=", type(client.client._transport)) | ||
| print("vars in transport in client=", vars(client.client._transport)) | ||
| litellm_created_session = client.client._transport._get_valid_client_session() | ||
| print("litellm_created_session=", litellm_created_session) | ||
| # check session ssl | ||
| print("litellm_created_session ssl=", litellm_created_session.connector._ssl) | ||
|
|
||
|
|
||
| # create aiohttp transport with ssl_verify=False | ||
| import aiohttp | ||
| aiohttp_session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) | ||
| print("aiohttp_session ssl=", aiohttp_session.connector._ssl) |
There was a problem hiding this comment.
[nitpick] Remove or replace debug print statements in tests; use assertions directly or a logger if needed to avoid noisy output in CI.
| print("type of transport in client=", type(client.client._transport)) | |
| print("vars in transport in client=", vars(client.client._transport)) | |
| litellm_created_session = client.client._transport._get_valid_client_session() | |
| print("litellm_created_session=", litellm_created_session) | |
| # check session ssl | |
| print("litellm_created_session ssl=", litellm_created_session.connector._ssl) | |
| # create aiohttp transport with ssl_verify=False | |
| import aiohttp | |
| aiohttp_session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) | |
| print("aiohttp_session ssl=", aiohttp_session.connector._ssl) | |
| assert isinstance(client.client._transport, object), "Transport type is not as expected" | |
| assert vars(client.client._transport), "Transport variables are missing or empty" | |
| litellm_created_session = client.client._transport._get_valid_client_session() | |
| assert litellm_created_session is not None, "litellm_created_session is None" | |
| # check session ssl | |
| assert litellm_created_session.connector._ssl is False, "SSL verification is not disabled in litellm_created_session" | |
| # create aiohttp transport with ssl_verify=False | |
| import aiohttp | |
| aiohttp_session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False)) | |
| assert aiohttp_session.connector._ssl is False, "SSL verification is not disabled in aiohttp_session" |
| from litellm._logging import verbose_logger | ||
|
|
||
| AIOHTTP_EXC_MAP = { | ||
| AIOHTTP_EXC_MAP: Dict = { |
There was a problem hiding this comment.
Annotate the exception map with concrete types, e.g., Dict[Type[Exception], Type[Exception]], to improve readability and static analysis.
| AIOHTTP_EXC_MAP: Dict = { | |
| AIOHTTP_EXC_MAP: Dict[Type[BaseException], Type[BaseException]] = { |
| # Network related exceptions | ||
| aiohttp.ClientConnectorError: httpx.ConnectError, | ||
| aiohttp.ClientOSError: httpx.ConnectError, | ||
| aiohttp.ClientConnectorError: httpx.ConnectError, |
There was a problem hiding this comment.
This key is duplicated in AIOHTTP_EXC_MAP; remove one occurrence to avoid confusion and ensure a single mapping per exception.
| aiohttp.ClientConnectorError: httpx.ConnectError, |
| aiohttp.ConnectionTimeoutError: httpx.ConnectTimeout, | ||
| aiohttp.SocketTimeoutError: httpx.ReadTimeout, | ||
| # Proxy related exceptions | ||
| aiohttp.ClientProxyConnectionError: httpx.ProxyError, |
There was a problem hiding this comment.
Duplicate mapping for ClientProxyConnectionError found; consolidate into one entry.
| aiohttp.ServerDisconnectedError: httpx.ReadError, | ||
| # Response related exceptions | ||
| aiohttp.ClientConnectionError: httpx.NetworkError, | ||
| aiohttp.ClientPayloadError: httpx.ReadError, |
There was a problem hiding this comment.
The ClientPayloadError mapping appears twice; deduplicate this entry to keep the map clear and unambiguous.
| aiohttp.ClientPayloadError: httpx.ReadError, |
aiohttp.ClientPayloadError aiohttp.ClientPayloadError and ssl_verification settings
…loadError` and ssl_verification settings (BerriAI#11162) * fix: AiohttpResponseStream transport * fix: use AiohttpResponseStream transport by default * fix: AiohttpResponseStream transport * fixes: mapping aiohttp exceptions * fixes: aiohttp rollout * fixes: add support ssl_verify for aiohttp * fixes: add support ssl_verify for aiohttp * fixes: remove duplicates
[Fixes] Aiohttp transport fixes
This PR enhances the Aiohttp transport by adding explicit handling for aiohttp.ClientPayloadError, ensures ssl_verify
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
🆕 New Feature
✅ Test
Changes