Skip to content

Legacy session messages fail after schema updates #27701

@shantur

Description

@shantur

Older local sessions can contain message and part rows written before the current MessageV2 schemas required several fields. After upgrading opencode, reading those sessions can fail because API/read paths hydrate the historical DB rows and then validate or serve them as the current message shape.

This is not limited to import/export. It can affect existing local sessions through endpoints and services such as:

  • GET /session/:id/message
  • GET /session/:id/message/:messageID
  • MessageV2.page
  • Session.messages
  • MessageV2.get
  • MessageV2.parts

Observed example error from a legacy session shape:

Missing key
  at ["agent"]

Legacy rows may also be missing fields that are now required, including:

  • message agent
  • user message model
  • assistant message parentID
  • step-finish.reason

The fix should preserve strict current schemas while normalizing historical rows at the read/import boundary so old sessions continue to work after upgrades.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions