anomalyco / anomalyco/opencode

attachments: dragging file or pasting file path into input fails session setup (Prompt.Base64 500 on /prompt)

Open
#45,558 3 comments 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 27, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

After updating to v0.0.0-beta-18387, dragging a file into the TUI input box, or copying a file path and pasting it into the input, causes the session to fail to start. The server returns HTTP 500 on POST /api/session/<id>/prompt because the file is treated as an image attachment and its base64 payload fails the Prompt.Base64 schema validation. Result is surfaced to the user as "Failed to set up session".

Environment

  • opencode version: v0.0.0-beta-18387
  • OS: Windows 10.0.26200.9168 (win32 x64)
  • Terminal: TERM=xterm-256color (launched via Git bash)
  • Shell: COMSPEC=C:\WINDOWS\system32\cmd.exe (opencode config shell: "bash")
  • Install/channel: beta
  • Active plugins: none found in config

Reproduction

  1. Launch the TUI with opencode2 (no config/images involved — global opencode.json has no embedded base64 images, project has no opencode.json).
  2. In the input box, either:
    • drag a file (e.g. a source/text file) into the input, or
    • copy a file path and paste it into the input.
  3. Send the message (this is typically the first prompt of the session).
  4. Observe "Failed to set up session" in the TUI.

Pure-text first messages work fine; only messages that contain a dragged file or a pasted file path trigger the failure.

Expected Behavior

Dragging a file or pasting a file path into the input should attach/reference the file as a file (text/context), not route it through the image-attachment base64 path. The session should set up and the message should be delivered.

Actual Behavior

The server logs a 500 with a schema validation error originating from the image-attachment normalization path:

POST /api/session/<id>/prompt  http.status=500
cause: Error: Schema validation failed
  at Session.normalizeImageAttachment (...)
  at Session.materializeAttachment (...)
  at Session.resolvePrompt (...)
  at Session.prompt (...)
  [cause]: expected "a string matching the RegExp ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
           identifier: "Prompt.Base64"

The attached file content (or the pasted path data, which can include a data:image/...;base64, prefix or other non-base64 characters) does not satisfy the strict Prompt.Base64 pattern, so the prompt is rejected before the model is ever called.

Additional Context

  • The failure is consistent (100% reproducible) on this version whenever the first message carries a dragged file or pasted file path.
  • The same action worked before the update; this appears to be a regression in v0.0.0-beta-18387.
  • Workaround: avoid drag-drop / paste-path; reference files with the @ file-reference (mention) syntax instead, which goes through the text/context channel and does not trigger image base64 validation.
  • The background service itself is healthy (opencode2 service status returns a valid address); the failure is isolated to the prompt-with-attachment handling.

Redacted server log excerpt (username/workspace paths removed):

timestamp=... level=INFO run=de674f6b cause="Error: Schema validation failed
    at Session.normalizeImageAttachment (...)
    at Session.materializeAttachment (...)
    at Session.resolvePrompt (...)
    at Session.prompt (...)
  [cause]: Error: {... "expected":"a string matching the RegExp ^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$", "identifier":"Prompt.Base64" ...}
" http.span=387 role=server http.method=POST http.url=/api/session/<id>/prompt http.status=500

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.