Repository navigation
fix(persistence): run validate on migrated state - #11
Merged
Merged
Conversation
bcheung
force-pushed
the
fix/validate-migrated-state
branch
from
November 6, 2026 03:56
7fc4d65 to
9825a54
Compare
bcheung
marked this pull request as ready for review
November 6, 2026 03:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
createPersister({ validate })is documented as "return false to reject the persisted state", but it only ran on state saved by the current version. When a version bump triggeredmigrate, the migrated state was returned straight away andvalidatewas skipped. A migration that produces bad data (a renamed field it missed, an invalid step) reached the flow even though the app had a check that would reject it.Now every restore goes through
validate, migrated or not:Behavior change: migrated state that
validaterejects is now discarded instead of restored. Released as a minor bump.Type of Change
Checklist
bun run test)bun run typecheck)bun run check)bun changeset)Testing
bun run test: 390 tests pass. Adds a case wherevalidaterejects migrated state (returnsnull, reportsvalidation_rejectedwithfromVersion/toVersion, skipsonRestore), and assertsvalidatenow runs on successful migrations.validateruns on every restore.