Skip to content

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

Open
rogerdigital wants to merge 1 commit intoanomalyco:devfrom
rogerdigital:fix/cli-file-mime-type
Open

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

Conversation

@rogerdigital
Copy link
Copy Markdown

@rogerdigital rogerdigital commented May 7, 2026

Issue for this PR

Closes #16723
Closes #24698
Closes #25353

Type of change

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

What does this PR do?

The --file flag on opencode run hardcodes MIME type as text/plain for all non-directory attachments. This means images, PDFs, and other binary files get the wrong content type, which causes providers to reject or misinterpret them.

The fix replaces the hardcoded string with a call to the existing Filesystem.mimeType() utility, which looks up MIME from the file extension. Unknown extensions fall back to application/octet-stream per RFC 2046.

This is the same one-line change as #24933 which has been waiting on review for over a week.

How did you verify your code works?

  • bun typecheck passes (full turbo typecheck across all 13 packages)
  • Manual test: opencode run --file screenshot.png "describe" correctly sends image/png
  • Manual test: opencode run --file notes.txt "summarize" still sends text/plain

Screenshots / recordings

N/A — no UI change.

Checklist

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

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #25317 - "fix: detect file MIME type from extension for -f attachments"

This PR appears to address the exact same issue: detecting MIME types from file extensions for file attachments instead of hardcoding them as text/plain. It's a direct duplicate of the current PR #26152, addressing the same functionality.

Note: PR #24933 also appears in search results with the same title, and your PR description indicates it's stale and being superseded by the current PR #26152.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

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

…/plain

The --file flag on `opencode run` was sending all non-directory
attachments as text/plain, breaking multimodal support for images,
PDFs, and other binary files. Use Filesystem.mimeType() to detect
the correct type from the file extension.

Closes anomalyco#16723, anomalyco#24698, anomalyco#25353
@rogerdigital rogerdigital force-pushed the fix/cli-file-mime-type branch from 38a127b to 42ad864 Compare May 7, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant