Repository navigation
fix: use the status code as the error body when it has no name - #170
Merged
Phillip9587 merged 2 commits intoOct 21, 2026
Merged
Conversation
In production, getErrorMessage() fell back to statuses.message[status], which is undefined for a valid error status that has no name, such as 499. The response body was <pre>undefined</pre>. Fall back to the status code itself, as res.sendStatus() does in Express.
Contributor
|
I think the workflow failures are from supertest (see expressjs/body-parser#772). Can you pin supertest to 7.3.0 for now? |
Contributor
|
Thanks for your contribution! |
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.
Fixes #169
Hi! 🙂 In production,
getErrorMessage()falls back tostatuses.message[status]. A valid error status code that has no name, such as 499, gaveundefined, and the body was<pre>undefined</pre>.This change adds the status code itself as the last fallback, the same as
res.sendStatus()in Express. Codes that have a name keep their name. The HTTP/1 reason phrase for these codes is stillunknown, from Node, and this change does not touch it.Tests: one new case in
test/test.jsfor status 499 in production. It fails without the change. I also added a line toHISTORY.mdunderunreleased.Happy to change anything you prefer 🙌