Repository navigation
opencode run and HTTP POST /session/{id}/message fail with NOT NULL constraint failed: session_message.seq (1.15.13) #31413
Description
Description
Starting with OpenCode 1.15.13, every code path that creates a new session message fails immediately with a SQLite NOT NULL constraint violation on session_message.seq. The session is created and listed correctly, but the first message (and every subsequent one) cannot be inserted.
This blocks opencode run and the HTTP POST /session/{id}/message route. The failure is in the new-row insert path of appendMessage (called from session.next.agent.switched in the bundled SessionPrompt code). Existing sessions stored in the local DB continue to work; new sessions are unusable for any new message.
Plugins
None.
OpenCode version
1.15.13 (Homebrew, darwin/arm64)
Steps to reproduce
1. opencode run (any prompt)
$ opencode run --model opencode-go/minimax-m3 --dir "$PWD" \
--title warmup --dangerously-skip-permissions "echo hello"
Error: {
"name": "UnknownError",
"data": {
"message": "Unexpected server error. Check server logs for details.",
"ref": "err_c822fa6f"
}
}2. HTTP POST /session/{id}/message
$ opencode serve --port 4096 --hostname 127.0.0.1 &
$ curl -sS -X POST http://127.0.0.1:4096/session -H 'Content-Type: application/json' -d '{}'
{"id":"ses_1576d5db9ffeakrbrmYGMdq6dJ","slug":"glowing-panda", ...}
$ curl -sS -X POST http://127.0.0.1:4096/session/ses_1576d5db9ffeakrbrmYGMdq6dJ/message \
-H 'Content-Type: application/json' \
-d '{"model":{"providerID":"opencode-go","modelID":"minimax-m3"},
"parts":[{"type":"text","text":"Reply with just the word ok"}]}'
{"name":"UnknownError","data":{"message":"Unexpected server error. ...","ref":"err_37d9088b"}}Both opencode-go/minimax-m3 and minimax-coding-plan/MiniMax-M3 fail identically, so the bug is in OpenCode itself, not the provider.
3. Error from server log
ERROR service=server ref=err_37d9088b
error=NOT NULL constraint failed: session_message.seq
cause=SQLiteError: NOT NULL constraint failed: session_message.seq
at run (unknown)
at #run (bun:sqlite:185:20)
at appendMessage (/$bunfs/root/chunk-9re0szbd.js:2:62522)
at session.next.agent.switched (/$bunfs/root/chunk-9re0szbd.js:2:56643)
at pC (/$bunfs/root/chunk-9re0szbd.js:2:56588)
at tn (/$bunfs/root/chunk-9re0szbd.js:2:62564)
at <anonymous> (/$bunfs/root/chunk-9re0szbd.js:2:62753)
at SessionPrompt.createUserMessage
at SessionPrompt.prompt
at SessionHttpApi.prompt
failed
4. Local DB schema (intact)
CREATE TABLE `session_message` (
`id` text PRIMARY KEY,
`session_id` text NOT NULL,
`type` text NOT NULL,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
`data` text NOT NULL,
`seq` integer NOT NULL,
...
);
CREATE UNIQUE INDEX `session_message_session_seq_idx`
ON `session_message` (`session_id`, `seq`);seq has no DEFAULT. Existing rows all have a non-null seq, so the schema is intact. The bug is in appendMessage not providing a value for seq on the new-row insert.
Screenshot and/or share link
N/A — headless run, no UI. Server log lines included above.
Operating System
macOS 26 (darwin/arm64)
Terminal
iTerm2 (headless invocation; not relevant)
Suggested fix area
appendMessage in packages/opencode (bundled into chunk-9re0szbd.js). It should compute the next seq for the session (MAX(seq)+1 for the session, or 1 if it has no messages yet) before the INSERT, or the schema should give seq a DEFAULT.
Activity
github-actions commentedon Jun 8, 2026
This issue might be a duplicate of existing issues. Please check:
NOT NULL constraint failed: session_message.seqerror inappendMessage, same root cause analysis, same affected code path.coygeek commentedon Jun 8, 2026
Closing as a duplicate of #31204 — same SQLite error, same appendMessage → session.next.agent.switched path, same root cause (no seq on insert). This was filed from macOS 26 (Homebrew opencode 1.15.13), no plugins, so the trigger condition is more general than originally reported.