You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty image attachment is not caught because the guard reads the wrong part shape #46859
An empty image attachment is sent to the provider instead of being replaced with the error text.
unsupportedParts in packages/opencode/src/provider/transform.ts:416 guards against empty base64 image data. The guard reads part.image, so it only runs when the part type is image.
The prompt pipeline never produces that shape. session/message-v2.ts:220 pushes an attachment as { type: "file", url, mediaType, filename }, and convertToModelMessages converts it to a file model part. The guard therefore never sees a real attachment, and the empty image reaches the provider, which fails the request with its own error.
The two unit tests that cover the guard build the image shape by hand (test/provider/transform.test.ts:2451 and :2498), so they pass while the production path is broken.
Steps to reproduce
Run this from packages/opencode on ef27925:
import{convertToModelMessages}from"ai"constmsgs=awaitconvertToModelMessages([{id: "m1",role: "user",parts: [{type: "text",text: "What is in this image?"},{type: "file",url: "data:image/png;base64,",mediaType: "image/png",filename: "empty.png"},],},]asany)console.log(JSON.stringify(msgs[0].content,null,1))
[
{ "type": "text", "text": "What is in this image?" },
{ "type": "file", "mediaType": "image/png", "filename": "empty.png", "data": "data:image/png;base64," }
]
The part type is file, so ProviderTransform.message returns it unchanged. Attaching a 0-byte PNG in the TUI reproduces the same thing end to end.
Expected: the part is replaced with ERROR: Image file is empty or corrupted. Please provide a valid image., which is what the guard does today for the hand-built image shape.
OpenCode version
1.18.26 (built from ef27925 on dev)
Operating System
macOS 26.6.2
I have a fix and a regression test that drives the real convertToModelMessages path. I will open the PR against this issue.
Activity
Tarquinen commentedon Oct 20, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊