Skip to content

test(error-shape): also catch message: field leakage (#354)#355

Merged
CryptoJones merged 1 commit into
masterfrom
test/error-shape-message-field-leakage
May 19, 2026
Merged

test(error-shape): also catch message: field leakage (#354)#355
CryptoJones merged 1 commit into
masterfrom
test/error-shape-message-field-leakage

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

Closes #354.

Summary

Extends controller-error-shape.test.js to scan for message: err.message / message: error.message / message: String(error) / message: String(err) in addition to the existing error: patterns. Pure tightening — no existing occurrences.

Test plan

  • npm run lint && npm test — 794 passing (1 new assertion per existing test.each iteration, same test count).

Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/

`tests/unit/controller-error-shape.test.js` scanned for variants of
`error: String(err) / err.message / error.message` to catch the
original 137-occurrence leak that #140 cleaned up. But the
runtime-shipped response body uses `message:` as its key — and a
future contributor who writes `res.status(500).json({ message:
err.message })` would route around the global error-handler's
policy without the test catching the regression.

Extend the regex set to cover the parallel `message:` patterns:
  - `message: String(error)` / `message: String(err)`
  - `message: err.message`
  - `message: error.message`

A grep of `app/` confirms zero existing occurrences — this is a
pure-tightening change. The global error-handler in
`app/middleware/error-handler.js` is the ONE place allowed to echo
err.message (under err.expose === true); the test specifically
scans `app/controllers` and `app/middleware` so the handler's own
file is covered too — its `message = err.message` assignment is
NOT a `message: err.message` object-literal shape, so the regex
doesn't false-positive there.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@CryptoJones CryptoJones merged commit a9c420c into master May 19, 2026
3 checks passed
@CryptoJones CryptoJones deleted the test/error-shape-message-field-leakage branch May 19, 2026 19:33
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.

test(error-shape): only guards error: leakage, not message: leakage

1 participant