fix: preserve aiohttp raw response headers#26895
Conversation
|
|
Greptile SummaryThis PR fixes non-ASCII response header corruption in Confidence Score: 5/5Safe to merge — minimal, targeted fix with a focused regression test and no backwards-incompatible changes. Single-line change using No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/custom_httpx/aiohttp_transport.py | Single-line fix: passes raw_headers (bytes tuples) to httpx.Response instead of decoded headers, with fallback for objects lacking raw_headers. |
| tests/test_litellm/test_streaming_connection_cleanup.py | Adds a regression test with a fake aiohttp session that exposes raw_headers containing UTF-8-encoded Chinese characters, verifying they round-trip correctly through the transport layer. |
Reviews (1): Last reviewed commit: "fix: preserve aiohttp raw response heade..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
… #26275 Second batch of drip-213 reviews: - openai/codex#20465 derive PermissionProfile directly in test helper (merge-as-is) - BerriAI/litellm#26895 preserve aiohttp raw response headers for UTF-8 (merge-as-is) - BerriAI/litellm#26893 cache-read pricing in custom-cost path (merge-after-nits) - google-gemini/gemini-cli#26275 preserve non-text parts through hook translator (merge-after-nits)
Summary
raw_headersintohttpx.Responseso non-ASCII response header values are decoded by httpx from their original bytesraw_headersLiteLLMAiohttpTransportFixes #26548.
Validation
/tmp/uv-0.10.9-env/bin/uv run --extra proxy pytest tests/test_litellm/test_streaming_connection_cleanup.py -q/tmp/uv-0.10.9-env/bin/uv run --extra proxy black --check litellm/llms/custom_httpx/aiohttp_transport.py tests/test_litellm/test_streaming_connection_cleanup.py/tmp/uv-0.10.9-env/bin/uv run --extra proxy ruff check litellm/llms/custom_httpx/aiohttp_transport.py tests/test_litellm/test_streaming_connection_cleanup.py/tmp/uv-0.10.9-env/bin/uv run --extra proxy mypy litellm/llms/custom_httpx/aiohttp_transport.pygit diff --check -- litellm/llms/custom_httpx/aiohttp_transport.py tests/test_litellm/test_streaming_connection_cleanup.py