anomalyco / anomalyco/opencode

fs/list returns HTTP 500 for the project worktree root when serve is started in a non-git directory

Open
#40,053 0 comments 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 1, 2026.

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

Description

Description

When opencode serve is started in a directory that is not a git repository, the web UI directory picker is completely broken: it shows "No folders found" and every directory-related action fails. The server-side cause is that fs/list returns HTTP 500 for / — which is the project worktree itself in this scenario.

I know Project.resolve returning worktree / for non-git dirs is working as designed (see #38992), so this issue is about the fs API failing on its own worktree, not about the worktree resolution.

Plugins

None.

OpenCode version

1.18.11

Steps to reproduce
  1. Start the server in a non-git directory (e.g. a fresh VM home dir):

    cd /root   # NOT inside a git repository
    opencode serve --port 34192 --hostname 0.0.0.0
    
  2. The project worktree resolves to /:

    curl -u opencode:<password> http://127.0.0.1:34192/project/current
    # {"id":"global","worktree":"/", ...}
    
  3. Listing the worktree itself returns HTTP 500, even though / contains 23 entries:

    curl -u opencode:<password> "http://127.0.0.1:34192/api/fs/list?path=/"
    # HTTP 500
    # {"name":"UnknownError","data":{"message":"Unexpected server error. Check server logs for details.","ref":"err_..."}}
    
  4. Same 500 for any path outside the startup directory: /tmp, /etc, /var.

  5. Starting inside a git repo works fine: worktree resolves to the repo path and fs/list returns 200.

Screenshot and/or share link

No share link available (headless server). Can attach screenshot of the web UI empty picker if needed.

Operating System

Ubuntu 24.04 (server) / Safari on iOS (web UI client)

Terminal

None — web UI only.

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.