anomalyco / anomalyco/opencode

Missing data migration for tool-part state.input on upgrade 1.14.28 → 1.18.18

Open
#44,688 5 comments 0 reactions 1 assignee View on GitHub

@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
  1. 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 todowrite todos arrives as a string (#34652). The errored part is stored with state.input as a string (it can be a truncated partial, so not always valid JSON).
  2. Upgrade opencode to 1.18.18 and start it (schema/DB migrations run).
  3. GET /session/:id/message for 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

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.