anomalyco / anomalyco/opencode

v2: silent 500 on session create when server schema mismatches the live database

Open
#39,775 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What happened

Running a V2 server built from a worktree (bun run src/index.ts --standalone <dir> or serve) against the live data directory (~/.local/share/opencode) fails every session create, and all three layers of the stack swallow the error:

  1. The server responds 500 with an empty body and logs nothing (no error, not even a request line for the create).
  2. The TUI wraps the call in .catch(() => undefined), discarding whatever detail existed.
  3. The user sees the generic toast "Creating a session failed. Open console for more details." and the console is empty.

Reads work fine against the same database (session list, catalog, events stream), which makes it look like the server is healthy. The likely cause is schema drift: the installed next-channel build has migrated the SQLite database past what the worktree commit expects, so writes fail while reads still happen to succeed.

Repro

  1. Have an up-to-date installed opencode2 that has run against ~/.local/share/opencode (migrations applied).
  2. From an older/divergent v2 worktree: bun run packages/cli/src/index.ts --standalone <some-dir>.
  3. Type a prompt on home and submit.
  4. Toast: "Creating a session failed." Nothing in opencode-local.log. curl -X POST .../api/session reproduces the bare 500 with empty body.

Pointing the same worktree server at fresh XDG dirs (isolated XDG_DATA_HOME etc.) makes creates return 200 immediately, which is how I isolated it.

Expected

Either of these would have saved the debugging time, both seem worth doing:

  • Server: refuse to start (or fail the request loudly) on a schema version mismatch, with a logged error and a real error body naming the expected vs found schema version.
  • TUI: surface the create failure detail in the toast/console instead of .catch(() => undefined) → generic message.

Environment

  • macOS, bun 1.3.14
  • Observed on origin/v2 worktree builds vs an installed next-channel service sharing ~/.local/share/opencode

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.

Research direction

Start by reproducing the failure with packages/cli/src/index.ts --standalone against the shared data directory, then inspect the /api/session create path and the TUI .catch(() => undefined) call. Compare behavior with isolated XDG directories and use opencode-local.log and curl to verify that a schema mismatch produces a logged, non-empty error or visible failure detail.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, sqlite, typescript
Domain
api, backend, databases, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.