Skip to content

Preserve saved progress when Edit State receives invalid JSON - #56

Open
Chessing234 wants to merge 1 commit into
teorth:masterfrom
Chessing234:codex/qed-import-validation
Open

Chessing234 wants to merge 1 commit into
teorth:masterfrom
Chessing234:codex/qed-import-validation

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

Pasting malformed JSON into Edit State currently clears saved exercise progress before parsing throws. Valid JSON such as null, an array, or a scalar also clears progress without providing a usable state.

Parse and validate a non-null JSON object before clearing storage. Invalid input displays an error and preserves progress; valid objects, including an intentional empty object, retain the existing import behavior.

Validation: node --test tests/edit-state.test.js passes all 8 tests. The six invalid-input cases fail on upstream master and pass with this change. The tests invoke the actual Edit State button callback with an isolated storage/DOM harness. node --check docs/js/gui.js and git diff --check also pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant