Repository navigation
fix(proxy): keep image-edit uploads as files instead of strings (#41421) - #41428
nikolas-sapa wants to merge 5 commits into
Conversation
|
| @@ -0,0 +1,151 @@ | |||
| """Regression test for BerriAI/litellm#41421. | |||
There was a problem hiding this comment.
This bug fix creates a separate test file, violating the requirement to extend the existing mapped endpoint and transformation tests before merging
Context Used: CLAUDE.md (source)
| # Drop raw file keys parsed from the multipart body. The File() params | ||
| # above are the source of truth (they capture every repeat of `image[]`); | ||
| # leaving the collapsed UploadFile/str behind would let downstream | ||
| # flattening `str()` it into a form field OpenAI rejects as | ||
| # "expected a file, but got a string instead" (#41421). |
There was a problem hiding this comment.
This comment restates straightforward filtering, violating the requirement to reserve source comments for genuinely complex business logic before merging
| # Drop raw file keys parsed from the multipart body. The File() params | |
| # above are the source of truth (they capture every repeat of `image[]`); | |
| # leaving the collapsed UploadFile/str behind would let downstream | |
| # flattening `str()` it into a form field OpenAI rejects as | |
| # "expected a file, but got a string instead" (#41421). |
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
8703dd5 to
6f438da
Compare
|
@greptile-apps re-review please — the three P2 findings (misplaced test file, Any types, redundant comment) were addressed in 6f438da: tests moved into the mapped endpoint/transformation test files, the new file deleted, and the source comment removed. |
3774b84 to
5720a49
Compare
cd43a3d to
25cf74d
Compare
|
Thanks for the fix and for the quick turnaround on review feedback, @nikolas-sapa — much appreciated. Heads up so you do not spend more time on it: the underlying bug (#41421) was fixed and shipped in #39512, which landed on main yesterday, so this PR is now superseded. Closing it out — sorry for the duplicated effort, and thanks again for the report and the patch. |
Fixes #41421.
Sending an
image[]file to the proxy/v1/images/editsendpoint failed with "Invalid type for 'image[0]': expected a file, but got a string instead."Cause:
_read_request_bodyleft the collapsedimage[]entry in the parsed body, while the real uploads were converted separately to BytesIO lists. Downstream flattening thenstr()-ed the leftover into a form field.Changes (isolated scope):
litellm/proxy/image_endpoints/endpoints.py: drop rawimage/image[]/mask/mask[]keys from the parsed body (theFile()params are the source of truth), and 422 when those fields arrive as plain strings.litellm/llms/openai/image_edit/transformation.py: keep the BytesIO.nameset by the proxy instead of hardcodingimage.png/mask.png.Regression coverage lives in
tests/test_litellm/proxy/image_endpoints/test_endpoints.pyandtests/test_litellm/llms/openai/test_openai_image_edit_transformation.py. The earlier standalonetest_image_edit_upload.pywas removed when the tests moved into these mapped files. This description update does not represent a new local test run.