server: v2.0.26 fails to decode messages created by earlier engine versions — GET /api/session returns 500 and all chat history appears lost
Summary
After the OpenCode engine was upgraded from 1.18.x to 2.0.26, the v2 server fails to
decode message rows created by earlier engine versions. The session list endpoint
(GET /api/session) then returns 500, so every workspace's chat history renders
empty and all prior chats appear lost.
Environment
- opencode version: 2.0.26 (channel=latest), started via
opencode serve --hostname 127.0.0.1 --port 0 - Bundled as a sidecar in the OpenWork desktop app (
com.differentai.openwork); engine v2 runs behind the app's "engine-v2-preview" - Sessions/live database shared with earlier engine versions 1.18.30 / 1.18.31 (
~/.local/share/opencode/opencode.db) - OS: Darwin 25.6.0 (darwin arm64)
- Terminal: GUI app (not a terminal)
- Shell: /bin/zsh
- Install/channel: latest channel sidecar binary
- Active plugins: OpenWork-managed local state plugins (context-plugin, mcp-readiness-plugin, mcp-results-plugin, provider-sync-plugin)
Reproduction
- Create sessions with an earlier engine (1.18.x) so
message.datarows use the older shape, e.g.:{"role":"user","time":{"created":1790613287160},"agent":"openwork","model":{...},"system":"...","summary":{"diffs":[]}} - Upgrade the engine to 2.0.26 against the same database and start
opencode serve. - Call
GET /api/session(session list) orGET /api/session/{id}/messagefor an affected session.
Expected Behavior
Per the V1→V2 migration guide, sessions and messages created by earlier versions should remain readable in V2. The session list should succeed and prior chats should still be visible.
Actual Behavior
- Server log shows repeated decode failures (63 occurrences and counting), e.g.:
level=ERROR run=5052a6de message="failed to decode session message" sessionID=ses_f17bcdc0affe1pAs5TIx3oiSzC messageID=msg_0e8de707b000027529c9d8f542 GET /api/session/{id}/messagereturns HTTP 500 for affected sessions. The affectedmessage.datarows are valid JSON (json_valid(data) = 1).- The session list call also fails for workspaces/directories that contain no affected session of their own, so every workspace's chat list renders empty, which looks like total data loss in the UI.
- Sessions without affected messages still load and read normally (verified by reading one migrated session's transcript successfully on engine v2).
- Affected sessions observed so far (all created 2026-09-11 → 2026-10-02 by
engine 1.18.x):
ses_f6e818ab0ffem0Bg4cxJPxrYg3,ses_f50039643ffe9d25rMxY0tE3gZ,ses_f4fcd11c4ffeUwaMhBuZV5Jvu8,ses_f02398e09ffeGQ64XwsEAcCZqU,ses_f17bcdc0affe1pAs5TIx3oiSzC(47 failed requests).
Expected data safety
No data was lost: all 52 sessions and 2,389 messages created since March 2026 are still intact in the SQLite database (verified against a backup copy). The failure is purely a decode/compatibility regression in 2.0.26 that makes existing history unreadable via the API/UI.
Additional Context
- Workarounds tried: restarting the server, retrying reads — decode failure is consistent, not intermittent.
- The bug reproduces on every session-list request; the same session ID and message ID fail each time.
Server-side fix for the empty v2 chat list (unreadable chats skipped, migrated chats resolved without reading history): #6665
I'd like to work on this! @benjaminshafii @OmarMcAdam please assign me.
@apjaphet #6665 (released in v0.18.64) stops one unreadable chat from failing the whole list: /api/session now skips and logs chats the engine can't decode instead of returning 500. The bundled engine has also moved past 2.0.26 since. Could you check on v0.18.71 whether your chat history shows up again? If specific older chats are still missing, please say roughly how many.
@reachjalil Yes — checked on v0.18.71 (bundled engine 2.2.6): my chat history is fully back. GET /api/session now returns 200 with all 55 sessions, and the desktop chat list matches.
All five sessions named in the report are readable again — both via the API and opening normally in the UI. Log-wise, all 78 failed to decode session message errors are from Oct 22–23 on 2.0.26; zero since.
For completeness: the chat-v2 migration on Nov 20 (0.18.68→0.18.71) subsequently re-imported the entire history into session_v2 (55 sessions / 5,614 messages) with a clean PRAGMA integrity_check. The only chats not visible in my list are ~13 stored under two workspace directories that were deleted from disk — an environment artifact on my side, not the decode bug.
From my side this is resolved on 2.2.6 — thanks for the #6665 fix.