[PR #5704] fix: show user-friendly error for unsupported image formats #11541

Closed
opened 2026-02-16 18:16:23 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5704

State: closed
Merged: No


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5704 **State:** closed **Merged:** No --- ## 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
yindo added the pull-request label 2026-02-16 18:16:23 -05:00
yindo closed this issue 2026-02-16 18:16:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11541