Uh oh!
There was an error while loading. Please reload this page.
fix(opencode): validate clipboard content type on Linux - #23459
Conversation
On Linux, xclip/wl-paste output raw bytes even when clipboard contains text (not an image). The code only checked byteLength > 0, so text was incorrectly labeled as image/png and sent to the model, which failed with 'could not process image'. Use existing sniffAttachmentMime() to validate PNG magic bytes before returning clipboard content as an image. Fixesanomalyco#23458
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
The following comment was made by an LLM, it may be inaccurate: Potential Related PR Found:
|
h0wdee
commented
Apr 20, 2026
Updated PR description to match the template. All checks are passing. Could a maintainer remove the |
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
Summary
sniffAttachmentMime()before treating as PNG on LinuxRoot Cause
On Linux,
xclip -selection clipboard -t image/png -ooutputs raw bytes even when clipboard contains text. The code only checkedbyteLength > 0, so text (e.g. Unicode like¯\_(ツ)_/¯) was labeled asimage/pngand sent to the model, which failed with "could not process image".Fix
Use the existing
sniffAttachmentMime()function frommedia.tsto check for PNG magic bytes before returning clipboard content as an image. This is the same validation pattern used in thereadtool.Verification
echo '¯\_(ツ)_/¯' | xclip -selection cFixes#23458