anomalyco / anomalyco/opencode
Missing data migration for tool-part state.input on upgrade 1.14.28 → 1.18.18
@nexxeln is already working on this.
Since Aug 24, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Description
Upgrading opencode from 1.14.28 to 1.18.18 lacks a data migration to normalize existing tool-part state.input.
On 1.14.28 a tool part could be persisted with state.input as a JSON string (e.g. an errored/aborted tool call). On 1.18.18 the serialization schema requires state.input to be an object (Schema.Record), so re-encoding the stored part fails and the whole session can no longer be read. The schema/DB migrations run on upgrade, but nothing converts the pre-existing string values.
OpenCode version
Upgraded 1.14.28 → 1.18.18
Steps to reproduce
- On 1.14.28, run a session where a tool call errors while its arguments are a JSON-encoded string — e.g. the model emits an unavailable/invalid tool name, or
todowritetodosarrives as a string (#34652). The errored part is stored withstate.inputas a string (it can be a truncated partial, so not always valid JSON). - Upgrade opencode to 1.18.18 and start it (schema/DB migrations run).
GET /session/:id/messagefor that session.
Observed on step 3 — the whole endpoint returns 400:
{"name":"BadRequest","data":{"kind":"Body",
"message":"Expected object, got \"{...}\"\n at [N][\"parts\"][M][\"state\"][\"input\"]"}}
A data migration is needed to coerce legacy state.input string values to objects, falling back to {} when the string isn't valid JSON.
Plugins
none
Operating System
Linux
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.
Assessment
This issue has not been assessed yet.