Skip to content

The sentinel spelling of "did this throw declare a status?" can now delegate to ThrownHttpError.declaredStatus #8634

Description

@os-zhuang

Observation while implementing #8570 (PR #8633). Filed unassigned; nobody is on it.

What is there

packages/rest/src/package-publish-status-classification.test.ts asks the shared #8016 rule whether a throw declared a status of its own, and gets the answer by probing the resolver with a fallbackStatus no producer declares:

// line 402constdeclaredStatus=(error: unknown)=>resolveThrownHttpError(error,0).status!==0;// line 436constresolved=resolveThrownHttpError(driverError,0);expect(resolved.status).toBe(0);

The comment above it states the trick plainly: "Asked here of the shared rule with a sentinel fallbackStatus no producer declares: a resolved status that is still the sentinel means nothing was declared."

Why it is worth a card now

#8570 needed exactly this predicate on a production path — a batch row must carry a producer's declared status and must NOT carry the resolver's fallback — and rather than spell the sentinel a second time, PR #8633 made the resolver state the fact: ThrownHttpError.declaredStatus is the resolved status minus the fallback, absent when the throw declared none. resolveThrownHttpError(e, 0).status !== 0 and resolveThrownHttpError(e).declaredStatus !== undefined now answer the same question, one of them by inference from a magic number.

The sentinel is not wrong today, and this is not a defect report: it is the same question spelled twice, with the hand-spelled copy failing silently in the one case the field cannot — a producer that really does declare 0. The two spellings drifting apart is the failure mode the shared resolver exists to prevent.

Scope if picked up

Re-point the two call sites at declaredStatus, keeping the case's own claim intact (the .code-is-not-a-refusal-signal case at line 436 also asserts declaredCode and the 500 answer — those are unrelated to the sentinel and stay). Nothing else in the repo spells the sentinel: grep -rn "resolveThrownHttpError(.*, *0)" packages/ returns these two lines and the doc comment naming them.

Not urgent, no user-visible behaviour attached.


Generated by Claude Code

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions