httpStatusForError knew only 'NotFound', while about two hundred throw sites
in server/ spell it Meteor's way - 'not-found', 'board-not-found',
'list-not-found', 'user-not-found' and the rest. So DELETE of a missing
swimlane, and a board-member add naming nobody, answered 500 "Internal
server error" on a real server, while tests/restWriteRoutes404.test.cjs,
which stubs the helper, saw the 404 - found by
tests/playwright/specs/rest-write-routes-404.e2e.js while testing RaceBleed.
Any error name that is or ends in "not-found" is now a 404 with its message;
everything unknown is still a 500 that carries no detail.
tests/restNotFoundStatus.test.cjs runs the real helper, and fails on any
not-found spelling in server/ that it would not map.
Thanks to xet7 !
Posting a comment without the required `comment` parameter (or to a board
that does not exist) returned an HTTP 500 error page. The schema-validation
error thrown on insert is a circular object (SimpleSchemaValidationContext ->
SimpleSchema -> ...), and serializing it crashed the response writer with
"Converting circular structure to JSON".
- Add Meteor-free helpers (server/lib/apiResponseHelpers.js): safeJsonStringify
(crash-proof, falls back to {error} on circular structures), httpStatusForError
(maps to 401/403/404/500), validateCommentBody, extractErrorMessage.
- sendJsonResult now serializes via safeJsonStringify so a non-serializable
payload can no longer crash into a 500.
- checkBoardAccess/checkBoardWriteAccess/checkBoardAdmin throw a 404 instead of
a TypeError on board.members when the board does not exist.
- POST comment validates input (400 when comment missing); REST comment catch
blocks return the real status code instead of 200.
- Add 18 unit tests (server/lib/tests/apiResponseHelpers.tests.js).
- Update CHANGELOG upcoming.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>