[BUG]: ENOENT when image URL is treated as local file path — breaks TUI rendering #7662

Open
opened 2026-02-16 18:07:52 -05:00 by yindo · 1 comment
Owner

Originally created by @rynfar on GitHub (Jan 26, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

When a message contains a GitHub image URL (e.g., from pasting an image or referencing user-attachments), OpenCode treats the URL as a local file path and attempts to stat() it. This resolves the URL against the CWD, producing an invalid path like:

/Users/rynfar/repos/opencode-claude-provider/https:/github.com/user-attachments/assets/421a1663-bc87-449f-b50c-6a411baf6417

The Bun.file(filepath).stat() call then throws an unhandled ENOENT error that dumps raw into the TUI, breaking the display.

Root Cause

The code path that processes file attachments/content does not check whether a path is a URL (starts with http:// or https://) before calling stat(). URLs should either be fetched remotely or skipped, not treated as local filesystem paths.

Related

Similar to #8807 (same stat() code path, different trigger — deleted file vs URL-as-path).

Steps to reproduce

  1. Start OpenCode
  2. Paste or reference an image that produces a GitHub user-attachments URL
  3. Submit the message
  4. Observe the ENOENT error rendered in the TUI

Error Output

ENOENT: no such file or directory, stat '/Users/rynfar/repos/opencode-claude-provider/https:/github.com/user-attachments/assets/421a1663-bc87-449f-b50c-6a411baf6417'
  path: "/Users/rynfar/repos/opencode-claude-provider/https:/github.com/user-attachments/assets/421a1663-bc87-449f-b50c-6a411baf6417",
  syscall: "stat",
  errno: -2,
  code: "ENOENT"

Expected behavior

URLs should be recognized as remote resources and not passed to stat(). The code should check if a path starts with http:// or https:// before attempting filesystem operations.

Operating System

macOS

Terminal

Terminal / OpenCode TUI

OpenCode version

Latest

Originally created by @rynfar on GitHub (Jan 26, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description When a message contains a GitHub image URL (e.g., from pasting an image or referencing user-attachments), OpenCode treats the URL as a local file path and attempts to `stat()` it. This resolves the URL against the CWD, producing an invalid path like: ``` /Users/rynfar/repos/opencode-claude-provider/https:/github.com/user-attachments/assets/421a1663-bc87-449f-b50c-6a411baf6417 ``` The `Bun.file(filepath).stat()` call then throws an unhandled ENOENT error that dumps raw into the TUI, breaking the display. ### Root Cause The code path that processes file attachments/content does not check whether a path is a URL (starts with `http://` or `https://`) before calling `stat()`. URLs should either be fetched remotely or skipped, not treated as local filesystem paths. ### Related Similar to #8807 (same `stat()` code path, different trigger — deleted file vs URL-as-path). ### Steps to reproduce 1. Start OpenCode 2. Paste or reference an image that produces a GitHub `user-attachments` URL 3. Submit the message 4. Observe the ENOENT error rendered in the TUI ### Error Output ``` ENOENT: no such file or directory, stat '/Users/rynfar/repos/opencode-claude-provider/https:/github.com/user-attachments/assets/421a1663-bc87-449f-b50c-6a411baf6417' path: "/Users/rynfar/repos/opencode-claude-provider/https:/github.com/user-attachments/assets/421a1663-bc87-449f-b50c-6a411baf6417", syscall: "stat", errno: -2, code: "ENOENT" ``` ### Expected behavior URLs should be recognized as remote resources and not passed to `stat()`. The code should check if a path starts with `http://` or `https://` before attempting filesystem operations. ### Operating System macOS ### Terminal Terminal / OpenCode TUI ### OpenCode version Latest
yindo added the opentui label 2026-02-16 18:07:52 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 26, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8807: Unhandled ENOENT error with deleted file attachments (same stat() code path, different trigger)
  • #4967: File path duplicates causing ENOENT on server side
  • #4686: TUI sending absolute local paths causing ENOENT errors
  • #5380: TUI referencing local directory with attach --dir to remote server
  • #10154: Image clipboard paste not working (related attachment handling)
  • #9375: Image paste failing with file not found errors
  • #9512: Invalid image file processing breaking the session
  • #3910: File path parsing error during message submission

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 26, 2026): This issue might be a duplicate of existing issues. Please check: - #8807: Unhandled ENOENT error with deleted file attachments (same stat() code path, different trigger) - #4967: File path duplicates causing ENOENT on server side - #4686: TUI sending absolute local paths causing ENOENT errors - #5380: TUI referencing local directory with attach --dir to remote server - #10154: Image clipboard paste not working (related attachment handling) - #9375: Image paste failing with file not found errors - #9512: Invalid image file processing breaking the session - #3910: File path parsing error during message submission Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7662