anomalyco / anomalyco/opencode
v2: silent 500 on session create when server schema mismatches the live database
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:
- The server responds
500with an empty body and logs nothing (no error, not even a request line for the create). - The TUI wraps the call in
.catch(() => undefined), discarding whatever detail existed. - 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
- Have an up-to-date installed
opencode2that has run against~/.local/share/opencode(migrations applied). - From an older/divergent v2 worktree:
bun run packages/cli/src/index.ts --standalone <some-dir>. - Type a prompt on home and submit.
- Toast: "Creating a session failed." Nothing in
opencode-local.log.curl -X POST .../api/sessionreproduces 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/v2worktree builds vs an installed next-channel service sharing~/.local/share/opencode
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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