fix: raise ValueError when MIME type cannot be determined for file_uri#5220
Open
giulio-leone wants to merge 1 commit intogoogle:mainfrom
Open
fix: raise ValueError when MIME type cannot be determined for file_uri#5220giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone wants to merge 1 commit intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
Response from ADK Triaging Agent Hello @giulio-leone, thank you for creating this PR! It looks like you haven't signed the Contributor License Agreement (CLA) yet. Please visit https://cla.developers.google.com/ to sign it. Once you've done that, the "cla/google" check should pass. Thanks! |
When file_data.file_uri has no explicit MIME type and no recognizable extension, _get_content() previously fell back silently to application/octet-stream via _DEFAULT_MIME_TYPE. This broke providers that validate MIME types (e.g. Vertex AI for GCS URIs) without warning. Changes: - Raise ValueError with actionable guidance when MIME type cannot be determined and a file block would be constructed. Provider-specific text fallback paths (anthropic, vertex_ai non-gemini, etc.) still work without requiring MIME. - Propagate model= in the recursive _content_to_message_param() call for mixed function_response + file content, fixing incorrect provider detection on Vertex AI / Gemini. Fixes: google#5184
f8bee41 to
2f0d88b
Compare
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
Fixes #5184
When
file_data.file_urihas no explicit MIME type and no recognizable extension, the LiteLLM integration previously fell back silently toapplication/octet-streamvia_DEFAULT_MIME_TYPE. This broke providers that validate MIME types (e.g. Vertex AI for GCS URIs) without any warning.Changes
1. Raise
ValueErrorinstead of silent fallback (_get_content)_DEFAULT_MIME_TYPEfallback assignment when MIME type cannot be determined.ValueErrorwith actionable guidance is now raised only when a file block would actually be constructed (i.e. the provider requires it).2. Propagate
model=in recursive_content_to_message_param()callfunction_response+ file content now forwardsmodel=model, fixing incorrect provider detection (e.g. Vertex AI Gemini vs non-Gemini).Tests
test_content_to_message_param_user_message_file_uri_without_mime_type→ expectsValueErrortest_get_content_file_uri_default_mime_type→ expectsValueErrortest_get_content_file_uri_no_mime_text_fallback_still_works— verifies text fallback works without MIMEtest_content_to_message_param_recursive_model_propagation— verifies model forwarding keeps file blocks for vertex_ai/geminitest_content_to_message_param_recursive_model_propagation_fallback— verifies text fallback for vertex_ai non-geminiAll 248 tests pass (3 new, 2 updated).