fix(httpx): sanitize unread multipart headers in masked errors - #26633
fix(httpx): sanitize unread multipart headers in masked errors#26633samrusani wants to merge 2 commits into
Conversation
Greptile SummaryThis PR extracts the masked-request reconstruction in
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/llms/custom_httpx/http_handler.py | Extracts masked request construction into _build_masked_request; correctly pops content-length, transfer-encoding, and content-type in the RequestNotRead fallback so the rebuilt request no longer describes a multipart payload that was never attached. |
| tests/test_litellm/llms/custom_httpx/test_credential_leak_prevention.py | Adds test_handles_unread_multipart_request_content that constructs a real multipart httpx request and asserts the masked rebuild strips the URL secret, zeroes the body, sets content-length: 0, and removes content-type. All assertions match the new helper's behaviour. |
| tests/test_litellm/llms/openai/test_openai_image_edit_transformation.py | Adds test_transform_image_edit_request_with_bytesio_mask_list covering proxy-style BytesIO mask handling; removes unused image_edit and BufferedReader imports. No mock weakening detected. |
| tests/test_litellm/proxy/image_endpoints/test_azure_routes.py | Adds test_image_edit_route_with_mask exercising the proxy /v1/images/edits route with both image and mask files; uses TestClient + mocked litellm.aimage_edit — no real network calls. |
Reviews (9): Last reviewed commit: "fix(httpx): avoid masked request content..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bd6c9ef to
5b9281c
Compare
|
Rebased this PR onto current Validation run on the rebased head:
|
|
Updated the title and description to reflect the current incremental scope. #26718 already fixed the original |
|
@greptileai please review the current head under the reframed follow-up scope described above. |
5b9281c to
828538b
Compare
828538b to
3902a43
Compare
|
CI note: the current |
3902a43 to
f0b2b47
Compare
|
Rebased onto the current Validation:
The remaining immediate failures are inherited from the current staging base: @greptileai please review the updated diff. |
|
Maintainer rerun requested for the failed The shard passed 6,300 tests and failed only
Could a maintainer please rerun the failed job? No code change is indicated from this failure. |
f0b2b47 to
9d3475d
Compare
|
Rebased onto current Validation:
@greptileai please review the current head. |
Relevant issues
Follow-up to #26718 and #26552.
#26718 fixed the
RequestNotReadexception when a masked HTTP error is rebuilt from an unread streaming request. This PR addresses the remaining request-metadata inconsistency in that fallback.Pre-Submission checklist
make test-unitScreenshots / Proof of Fix
For an unread multipart image-edit request, the masked error wrapper must replace the unavailable body with
b"". Before this follow-up, the rebuilt request retained the original multipartContent-Type,Content-Length, and transfer metadata, so the diagnostic request described a multipart payload that was no longer attached.The regression test constructs a real
httpxmultipart request with bothimage[]andmaskstreams and verifies that the rebuilt masked request:Content-Length: 0Content-Typeor transfer metadataNo real provider call is required for this error-path test.
Type
Bug Fix
Test
Changes
image+maskhandling and proxy-styleBytesIOmasks.Tests
Current GitHub checks pass except the repository-wide OSV scan, which reports existing vulnerabilities in lockfiles this PR does not modify.
Scope
This intentionally does not change provider request construction, retries, transport behavior, or image-edit feature support.