Skip to content

fix(core): support legacy message rows#27702

Open
shantur wants to merge 2 commits into
anomalyco:devfrom
shantur:fix/import-legacy-session-agent
Open

fix(core): support legacy message rows#27702
shantur wants to merge 2 commits into
anomalyco:devfrom
shantur:fix/import-legacy-session-agent

Conversation

@shantur
Copy link
Copy Markdown
Contributor

@shantur shantur commented May 15, 2026

Issue for this PR

Fixes #27701 #21941 #25847

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Older local sessions can contain message and part rows written before the current MessageV2 schemas required several fields. After upgrading opencode, those historical rows can fail when read through session message APIs or services, not only when importing an old export.

This PR adds shared compatibility normalization in MessageV2 hydration and reuses it from import. Current schemas remain strict, but legacy rows are repaired at the read/import boundary before decoding or returning them.

The compatibility handling covers missing message agent, user model, assistant parentID, and step-finish.reason fields. The investigation found import started surfacing the issue when it moved from inserting raw message data to parsing through MessageV2.Info in 64fb9233b, but the same historical shape can affect existing local DB sessions through /session/:id/message and related read paths.

How did you verify your code works?

  • bun test test/cli/import.test.ts test/session/messages-pagination.test.ts from packages/opencode
  • bun typecheck from packages/opencode
  • Push hook ran repo bun turbo typecheck
  • Decoded the reported legacy session export with the shared normalizers and current MessageV2 schemas; all 3312 messages decoded successfully

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@shantur shantur changed the title fix(import): support legacy session exports fix(session): support legacy message rows May 15, 2026
@shantur shantur changed the title fix(session): support legacy message rows fix(core): support legacy message rows May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Legacy session messages fail after schema updates

1 participant