Skip to content

Fix Ten Things list value delete/clear causing 500 - #69

Merged
FlandersBurger merged 2 commits into
masterfrom
fix/tenthings-delete-value-500
Aug 8, 2026
Merged

Fix Ten Things list value delete/clear causing 500#69
FlandersBurger merged 2 commits into
masterfrom
fix/tenthings-delete-value-500

Conversation

@FlandersBurger

Copy link
Copy Markdown
Owner

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

  • Trash icon didn't save: removeValue in ListEditor.tsx only updated local React state via onChange, 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.
  • Clearing a value 500'd: PUT /api/tenthings/lists/:id called list.validate()/list.save() with no error handling. Mongoose's required: true check rejects empty strings for the value's value field, so blanking an answer and blurring threw an unhandled ValidationError that fell through to the app's catch-all handler as a bare 500.

Fix

  • removeValue now also fires a save, matching the pattern used elsewhere in the editor.
  • PUT /:id now rejects blank answers with a proper 400 { error: "Answers cannot be blank." } before saving, and wraps validate()/save() in try/catch returning 400 with the real validation message instead of crashing to 500.
  • Applied the same blank-answer guard to POST / (list creation), which shares the same shape of bug.

Testing

  • npx jest --selectProjects server --testPathPatterns="tenthings/lists" — 15/15 passing.
  • Confirmed Mongoose's required-string behavior with a standalone repro (rejects "").
  • Not manually verified end-to-end against a live dev server/DB in this environment — recommend a quick click-through (delete a value, clear-and-blur a value) before merge.

🤖 Generated with Claude Code

FlandersBurger and others added 2 commits July 26, 2026 21:45
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>
@FlandersBurger
FlandersBurger merged commit 3dc11ba into master Aug 8, 2026
3 checks passed
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