Skip to content

fix(cli): detect MIME type for --file flag instead of hardcoding text/plain#24933

Open
rogerdigital wants to merge 3 commits intoanomalyco:devfrom
rogerdigital:fix/file-flag-mime-type
Open

fix(cli): detect MIME type for --file flag instead of hardcoding text/plain#24933
rogerdigital wants to merge 3 commits intoanomalyco:devfrom
rogerdigital:fix/file-flag-mime-type

Conversation

@rogerdigital
Copy link
Copy Markdown

@rogerdigital rogerdigital commented Apr 29, 2026

Issue for this PR

Closes #24698

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The --file flag in opencode run always hardcoded text/plain as the MIME type, which prevented image files from being recognized as multimodal inputs by LLMs.

The fix replaces the hardcoded "text/plain" with a call to the existing Filesystem.mimeType() utility, which uses the mime-types library to look up the correct MIME type from the file extension. For example, .pngimage/png, .jpgimage/jpeg, unknown extensions → application/octet-stream.

One-line change in packages/opencode/src/cli/cmd/run.ts:331.

How did you verify your code works?

  • Typecheck passes across all 19 packages (pre-push hook runs bun turbo typecheck)
  • The Filesystem.mimeType() function already exists and is used elsewhere in the codebase (e.g. file/index.ts, project/project.ts)

Screenshots / recordings

N/A — CLI behavior change, no UI involved.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Bojun-Vvibe added a commit to Bojun-Vvibe/oss-contributions that referenced this pull request Apr 29, 2026
- anomalyco/opencode#24933 merge-after-nits: --file MIME detection fix
- anomalyco/opencode#24935 request-changes: in-tree pet+CAVA bundle, ship as plugin only
- openai/codex#20176 merge-after-nits: SessionSource via JSON deserialize is brittle
- openai/codex#20178 merge-as-is: 1714-line obsolete adapter deletion
@rogerdigital
Copy link
Copy Markdown
Author

One behavior change worth noting: unknown file extensions now fall back to application/octet-stream instead of text/plain. This matches RFC 2046 semantics for unknown binary content, but flagging it in case any provider has stricter rejection logic for that type.

@rogerdigital rogerdigital force-pushed the fix/file-flag-mime-type branch from e5df3c6 to aab5d6b Compare May 5, 2026 15:48
@rogerdigital rogerdigital force-pushed the fix/file-flag-mime-type branch from aab5d6b to 845067f Compare May 5, 2026 16:14
Sign up for free to 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.

CLI: --file flag attaches images with incorrect MIME type, breaking multimodal support

1 participant