fix(api): prevent upload filename collisions and reject unsupported image URLs#3187
Merged
Re-bin merged 3 commits intoHKUDS:mainfrom Apr 16, 2026
Merged
Conversation
…e URLs Three fixes in the API upload handling: 1. Multipart uploads now prefix filenames with a UUID to prevent overwrites when two requests upload files with the same name. 2. JSON image_url content blocks with remote HTTPS URLs now return a 400 error instead of silently dropping the image. 3. Model validation runs for both JSON and multipart requests, fixing an inconsistency where multipart bypassed the check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three fixes for the API upload handling in
/v1/chat/completions:{uuid}_{filename}), preventing overwrites when concurrent requests upload files with the same name. Base64 data URL uploads already used UUIDs and were not affected.image_urlcontent blocks with remote HTTPS URLs now return a 400 error with a clear message instead of silently dropping the image. Onlydata:base64 URLs are supported.Test plan
python-docxoptional dep)test_multipart_upload_saves_file— verifies file saving still works with UUID prefixtest_model_mismatch_returns_400— verifies model validation