Skip to content

[Bug]: ~/.spawn/history.json has no schema version — upgrades that change SpawnRecord shape silently corrupt history #2252

@louisgv

Description

@louisgv

What happened?

~/.spawn/history.json is read and written directly with no schema version field. The SpawnRecord and VMConnection shapes are validated on read via type guards (validateConnectionIP, validateLaunchCmd, etc.), but there is no version marker and no migration path.

Why this is a problem

When a new version of spawn adds, removes, or renames fields on SpawnRecord / VMConnection, users who upgrade with an existing history file will hit one of:

  1. Silent data loss — old fields are dropped, new required fields are undefined, and the record is treated as valid but incomplete
  2. Silent corruption — a new field repurposes an old key name with a different type/meaning
  3. Confusing errors — the type guards reject old records and history appears empty, with no explanation

There is no "your history format is from an older version, migrating…" path. Users who have accumulated many sessions over time (SSH keys, server IDs, agent preferences) could silently lose that data on upgrade.

Suggested fix

  1. Add a version field to the top-level history file structure (e.g., { "version": 1, "records": [...] })
  2. On read, check the version and run any necessary migrations before passing records to the rest of the app
  3. Before writing, stamp the current schema version

A minimal v1 migration would just be: "if no version field → this is v0 → apply v0→v1 transform". Keeps it simple while creating the escape hatch for future changes.


Filed from Slack by Ori

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsafe-to-workSecurity triage: safe for automated processing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions