Skip to content

fix: file()/video() forward computed MIME (#3) - #9

Merged
Khurdhula-Harshavardhan merged 1 commit into
mainfrom
fix/forward-file-mime
Jul 20, 2026
Merged

fix: file()/video() forward computed MIME (#3)#9
Khurdhula-Harshavardhan merged 1 commit into
mainfrom
fix/forward-file-mime

Conversation

@Abhinavexist

Copy link
Copy Markdown
Collaborator

Fixes#3

Problem

file()/video() computed the MIME but used it only for the blacklist check — format was added to the part only when the caller passed one explicitly. For an https-URL file/video part with no format, the server has no data-URL MIME to extract and falls back to:

// src/helpers/message.ts:318
mediaType: c.file?.format||dataUrlMime||"application/octet-stream"

So video("https://…/clip.mp4") reached model selection as application/octet-stream.

Fix

Forward the computed MIME as format (the server uses file.formatverbatim as mediaType, so the full type like video/mp4 is correct — this is the opposite of input_audio.format, which gets audio/ prepended). video() and auto_part inherit the fix through file().

Unknown-extension URLs still resolve to no MIME → no format key → the same application/octet-stream fallback as today (no regression).

Tests

Added: file() forwards application/pdf, video() forwards video/mp4, auto_part mp4 → video/mp4, and unknown-ext omits format. Suite: 27 passing; ruff + mypy --strict clean.

Note

The _inputs.py diff also carries the repo formatter's _EXT_MIME normalization (same as #7).

file()/video() computed the MIME only for the blacklist check and set
format only when the caller passed one. For an https-URL file/video part
with no explicit format, the server had no data-URL MIME to read and fell
back to application/octet-stream, undercutting file/video support.
Forward the computed MIME as format (the server uses file.format verbatim
as mediaType). video() and auto_part inherit this via file(). Unknown
extensions still yield no format, preserving the octet-stream fallback.

@Khurdhula-HarshavardhanKhurdhula-Harshavardhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

file()/video() drop computed MIME → server sees application/octet-stream

2 participants

@Abhinavexist@Khurdhula-Harshavardhan