Skip to content

LiteLLM silently uses application/octet-stream when file_uri MIME type cannot be determined #5184

Closed

Description

@YizukiAme

Bug Description

When file_data.file_uri has no explicit MIME type and the URI has no recognizable file extension, the LiteLLM integration silently falls back to application/octet-stream via _DEFAULT_MIME_TYPE. This causes incorrect file handling with providers that validate MIME types (e.g., Vertex AI for GCS URIs) without any warning to the developer.

Additionally, _content_to_message_param() does not propagate the model parameter in recursive calls for mixed function_response + file content, causing incorrect provider detection on Vertex AI / Gemini.

Steps to Reproduce

# A file_uri with no extension and no explicit MIME type
part = types.Part(file_data=types.FileData(
    file_uri="gs://bucket/artifact/0"
    # mime_type not set, no extension to infer from
))
# Result: silently uses "application/octet-stream"
# On Vertex AI, this leads to incorrect file handling

Expected Behavior

  • A clear error should be raised when MIME cannot be determined and a file block needs to be constructed, with guidance to set file_data.mime_type explicitly
  • Provider-specific text fallback paths should still work without requiring MIME

Actual Behavior

Silent fallback to application/octet-stream with a debug-level log that's easy to miss.

Activity

  1. added a commit that references this issue on Apr 8, 2026
    d149537
  2. added
    models[Component] This issue is related to model support
    on Apr 9, 2026
  3. added theissue type on Apr 9, 2026
  4. added 2 commits that reference this issue on Apr 9, 2026
    f8bee41
    2f0d88b
  5. added a commit that references this issue on Apr 9, 2026
    22344c3
  6. surajksharma07 commented on Jun 1, 2026

    @surajksharma07
    Collaborator

    @YizukiAme the debug-level fallback is definitely too quiet for something that silently breaks Vertex AI — that should at minimum be a warning, and the fail-fast ValueError approach in #5220 actually aligns better with what you described as expected behavior.

    Also worth noting: the model propagation issue in recursive calls appears already fixed in v1.34.1+, so you may not be seeing that one depending on your version.

    In the meantime, explicitly setting file_data.mime_type on your FileData is a reliable workaround — could you give that a try and confirm it holds for your GCS URI case?
    Once you've validated, let us know whether #5207 or #5220 fits better and we can prioritize accordingly!

  7. added
    request clarification[Status] The maintainer need clarification or more information from the author
    on Jun 1, 2026
  8. surajksharma07 commented on Jul 8, 2026

    @surajksharma07
    Collaborator

    Closing this out — the silent octet-stream fallback is actually gone as of v2.4.0, just landed via a different PR (#5023, fixing the duplicate #5022) rather than #5207 or #5220. file_data now raises a clear ValueError telling you to set file_data.mime_type explicitly instead of silently defaulting, so #5207 and #5220 are superseded and can probably be closed too.

    Give v2.4.0 a spin and reopen if you're still hitting the silent fallback there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

models[Component] This issue is related to model supportrequest clarification[Status] The maintainer need clarification or more information from the author

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions