Fix Ten Things list value delete/clear causing 500 - #69
Merged
Conversation
Asteroids.tsx no longer tracks a playing state that was never read (the game loop and canvas already use the gameRef.playing flag), and collapses the separate announce/announcement booleans into one string state. Login.tsx drops a dead manual login/register form left over from before the FirebaseUI migration, and TenThingsGame.tsx drops a duplicate unused dropdown-visibility state. src/client/tsconfig.json was accidentally excluding itself via an inherited exclude pattern, so tsc --noEmit -p src/client/tsconfig.json never actually ran anywhere (not in vite build, not in the pre-commit hook). Fixed the config and wired it up as `check:client`, run from the pre-commit hook, so unused client-side locals and other client TS errors are now caught automatically. Also fixed the real type errors that check surfaced (canvas possibly-null, gradient stop args, implicit any index, and an overly strict TenThingsValue._id type). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The trash icon in ListEditor only updated local state via onChange and never triggered a save, so deleting a value silently didn't persist. Now it saves immediately like every other field edit in the editor. Clearing an existing answer's text to blank and blurring did trigger a save, but PUT /:id called list.validate()/list.save() with no error handling. Mongoose's required check rejects empty strings, so this threw an unhandled ValidationError that fell through to the app's catch-all handler as a bare 500. Added an explicit blank-answer guard (400) plus a try/catch around validate/save that returns the real error message instead of crashing. Applied the same blank-answer guard to POST / (list creation) since it shares the same shape. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Problem
Deleting or blanking an answer in the Ten Things list editor was broken: the trash icon didn't persist, and clearing an answer's text returned a 500 from the API.
Root causes
removeValueinListEditor.tsxonly updated local React state viaonChange, never triggering a save — unlike every other edit in the component (name, categories, language, difficulty, value/blurb text). Deletions looked like they worked but were silently lost.PUT /api/tenthings/lists/:idcalledlist.validate()/list.save()with no error handling. Mongoose'srequired: truecheck rejects empty strings for the value'svaluefield, so blanking an answer and blurring threw an unhandledValidationErrorthat fell through to the app's catch-all handler as a bare500.Fix
removeValuenow also fires a save, matching the pattern used elsewhere in the editor.PUT /:idnow rejects blank answers with a proper400 { error: "Answers cannot be blank." }before saving, and wrapsvalidate()/save()intry/catchreturning400with the real validation message instead of crashing to500.POST /(list creation), which shares the same shape of bug.Testing
npx jest --selectProjects server --testPathPatterns="tenthings/lists"— 15/15 passing."").🤖 Generated with Claude Code