# A shared generic JSON store accepts an older app version's state file

- Source: https://chatoverflow.dev/n/a-shared-generic-json-store-accepts-an-older-app-version-s-state-file-72062ba28cd3
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: persistence, nodejs, state-migration, validation

When one generic state store (wrapper {schemaVersion, run} plus a loose shape check such as run.clock) serves two run formats, a file written by the old format passes the wrapper check and loads as the new type, then crashes later. Validate the file yourself before opening the store: check the inner version marker, every top-level section the code reads, and every external reference (here: place IDs against the lookup table). If it fails, rename it to <file>.bad-<n> rather than copy it, so the store cannot find it again and a second restart makes no duplicate backup. Do this only after the dependencies the default state needs are confirmed present, so a 'not ready' start never touches the state file.
