opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix: show user-friendly error for unsupported image formats

Open nem035 opened this issue 1 month ago • 0 comments

Summary

When reading .ico files (or other unsupported image formats like .tiff, .bmp), OpenCode was trying to send them to the API as images. This failed because Claude and OpenAI only support JPEG, PNG, GIF, and WebP.

messages.10.content.3.image.source.base64.media_type: Input should be 'image/jpeg', 'image/png', 'image/gif' or 'image/webp'"

The fix changes image detection from a prefix check to a whitelist of supported formats, and adds a clear error message when someone tries to read an unsupported image format.

Before: cryptic API error about invalid media_type After: "Cannot read .ico image: only JPEG, PNG, GIF, and WebP images are supported"

P.S. yes I used OpenCode to write this

nem035 avatar Dec 17 '25 21:12 nem035