Repository navigation
fix(data): save entries.json atomically and reject a boolean version - #202
Merged
jamesconwaydev merged 1 commit intoNov 6, 2026
Merged
Conversation
save() now writes a temp file beside entries.json and renames it over the old one, so a crash mid-write can no longer leave a broken file. The validator checked version with ==, so true and 1.0 passed as 1. It now needs the integer 1. Statuses are defined once, as the Status Literal, and STATUSES comes from it. A test checks they match schema.json, and the validator tests now assert the exact messages and the CLI exit codes.
jamesconwaydev
approved these changes
Nov 6, 2026
jamesconwaydev
left a comment
Collaborator
There was a problem hiding this comment.
Nice. The True == 1 catch is a good one, and tying STATUSES to the Literal (with the schema test) kills the drift for good. Same-directory temp file plus os.replace is exactly right.
4 of 5 tasks
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.
What and why
Closes #50.
save()writesentries.json.tmpbeside the target, thenos.replaces it over the original, so a crash or full disk mid-write leaves the old file intact. The temp file is removed if anything fails. Same directory, so the rename never crosses filesystems.True == 1and1.0 == 1in Python, so both passed. The CLI now requirestype(version) is int.Statusis theLiteral, andSTATUSES = get_args(Status). A new test checks thatschema.json's enum matches it, so the third copy can't drift either.version: true,version: 1.0, a non-listentries, a missingentries, a bad entry and invalid JSON.The save and CLI tests fail on
mainand pass here.Checks
python3 -m unittest discover -s scripts -t .passesnpm --prefix site testpasses (if you touchedsite/)npx prettier --check .passesdata/entries.jsonby hand (submissions go through the form)