Returns a status the web Response constructor will accept, clamping an
unserveable one to 500 and reporting it through the logger capability when
one is reachable.
The Response constructor throws RangeError for anything outside
[200, 599] and for a non-integer, and TypeError for a body on one of the
null-body statuses 204/205/304 (see NULL_BODY_STATUSES) —
any of which would make the error path itself the fault: the response the
caller asked for is replaced by an unhandled exception on the real serve
path. Three shipped call sites pass a status the
APPLICATION authors — FlagGuardOptions.statusCode, the multi-tenancy
rejectionStatus, and a WebSocketGuardDecision.status — so a plausible
typo such as 4004 for 404 crashes every request to that route.
Clamping to 500 rather than treating the status as absent is deliberate:
the caller definitely wants an error response and only the number is wrong.
Number.isInteger is checked BEFORE the range comparisons because NaN —
what a mis-derived status collapses to — satisfies neither < nor >, so a
bare range check would accept it and the constructor would then reject it
as 0.
inject() cannot observe any of this: it builds no native Response, so a
regression test must drive app.fetch.
Returns a status the web
Responseconstructor will accept, clamping an unserveable one to500and reporting it through the logger capability when one is reachable.The
Responseconstructor throwsRangeErrorfor anything outside[200, 599]and for a non-integer, andTypeErrorfor a body on one of the null-body statuses204/205/304(see NULL_BODY_STATUSES) — any of which would make the error path itself the fault: the response the caller asked for is replaced by an unhandled exception on the real serve path. Three shipped call sites pass a status the APPLICATION authors —FlagGuardOptions.statusCode, the multi-tenancyrejectionStatus, and aWebSocketGuardDecision.status— so a plausible typo such as4004for404crashes every request to that route.Clamping to
500rather than treating the status as absent is deliberate: the caller definitely wants an error response and only the number is wrong.Number.isIntegeris checked BEFORE the range comparisons becauseNaN— what a mis-derived status collapses to — satisfies neither<nor>, so a bare range check would accept it and the constructor would then reject it as0.inject()cannot observe any of this: it builds no nativeResponse, so a regression test must driveapp.fetch.