fix(cli): detect MIME type for --file flag instead of hardcoding text/plain#26152
Open
rogerdigital wants to merge 1 commit intoanomalyco:devfrom
Open
fix(cli): detect MIME type for --file flag instead of hardcoding text/plain#26152rogerdigital wants to merge 1 commit intoanomalyco:devfrom
rogerdigital wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #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. |
Contributor
|
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
38a127b to
42ad864
Compare
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.
Issue for this PR
Closes #16723
Closes #24698
Closes #25353
Type of change
What does this PR do?
The
--fileflag onopencode runhardcodes MIME type astext/plainfor 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 toapplication/octet-streamper 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 typecheckpasses (full turbo typecheck across all 13 packages)opencode run --file screenshot.png "describe"correctly sendsimage/pngopencode run --file notes.txt "summarize"still sendstext/plainScreenshots / recordings
N/A — no UI change.
Checklist