fix: omit mimeType from fileData for YouTube and extensionless URLs#442
Merged
mikehostetler merged 3 commits intoFeb 20, 2026
Merged
Conversation
Google's convert_content_part/1 unconditionally added mimeType to all fileData parts. For YouTube URLs (no file extension), this resulted in "application/octet-stream" which Gemini rejects with a 400 error. Extract build_file_data/2 helper that omits mimeType when the inferred type is nil or octet-stream, letting Gemini infer it. Also preserve media_type through OpenAI content part encoding so explicit types aren't dropped. Closes agentjido#433
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
build_file_data/2helper in the Google provider that conditionally includesmimeTypenilor"application/octet-stream"(unrecognizable extension),mimeTypeis omitted entirely from thefileDatamapmedia_typefromContentPart.image_url/1through the OpenAI encoding layer indefaults.exRoot cause
infer_mime_type_from_url/1falls back to"application/octet-stream"for URLs without a recognizable file extension (e.g.,youtube.com/watch?v=...). This was unconditionally added tofileData, causing Gemini to reject the request with:Files changed
lib/req_llm/providers/google.exbuild_file_data/2, conditionally omitmimeTypelib/req_llm/provider/defaults.exmedia_typeinencode_openai_content_partfor:image_urltest/providers/google_test.exsTest plan
mix testpasses (2164 tests, 0 failures)mix compile --warnings-as-errorspassesmimeTypemimeType.mp4,.jpg, etc.) still producemimeTypeCloses #433