Skip to content

feat: add 'strict status codes' setting - #7215

Closed
oldregime wants to merge 1 commit into
expressjs:5.0from
oldregime:feat/strict-status-codes
Closed

feat: add 'strict status codes' setting#7215
oldregime wants to merge 1 commit into
expressjs:5.0from
oldregime:feat/strict-status-codes

Conversation

@oldregime

Copy link
Copy Markdown

Summary

This PR implements the 'strict status codes' setting for Express v5, as discussed in #5623.

Changes

  • Updated res.status to check for the 'strict status codes' application setting.
  • When enabled, status codes are restricted to the range 100-599 (RFC standard).
  • When disabled (default), the range remains 100-999 for backward compatibility.
  • Added comprehensive tests in test/res.status.strict.js covering enabled/disabled states and boundary cases.

Verification

  • All 16 existing tests in test/res.status.js pass.
  • All new tests in test/res.status.strict.js pass.
  • Linting (eslint) is clean.

This implements the agreed-upon behavior for Express v5 to allow
locking down valid status code ranges to 1xx-5xx (RFC standard)
when the 'strict status codes' setting is enabled.
By default, the range remains 100-999 for backward compatibility.
Addresses: expressjs#5623
@krzysdz

Copy link
Copy Markdown
Contributor

Duplicate of#5856

@krzysdzkrzysdz marked this as a duplicate of #5856May 4, 2026
@krzysdzkrzysdz closed this May 4, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@oldregime@krzysdz