From a8aca740c7b6f767009860622046282d9dfbae42 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 15 Aug 2026 04:07:52 +0000 Subject: [PATCH] test(rest): re-point the publish-classification sentinel at ThrownHttpError.declaredStatus `package-publish-status-classification.test.ts` asked the shared #8016 rule whether a throw declared a status of its own by hand-probing `resolveThrownHttpError` with a sentinel `fallbackStatus` (0) no producer declares. PR #8633 gave the resolver a field that states this fact directly -- `ThrownHttpError.declaredStatus`, present exactly when the throw declared a status, absent when it did not. Re-point both call sites at that field instead of the hand-spelled sentinel: - the `declaredStatus` helper: `resolveThrownHttpError(error, 0).status !== 0` -> `resolveThrownHttpError(error).declaredStatus !== undefined` - the driver-`code` case: `resolveThrownHttpError(driverError, 0)` / `expect(resolved.status).toBe(0)` -> `resolveThrownHttpError(driverError)` / `expect(resolved.declaredStatus).toBeUndefined()` The case's own unrelated claim -- `declaredCode` and the re-thrown 500 / INTERNAL_ERROR answer -- is untouched. Test file only, no production change (`ThrownHttpError.declaredStatus` already landed in #8633). Fixes #8634 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01NaS1PAHJcPfAA2acnV53Tn --- ...ackage-publish-status-classification.test.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/rest/src/package-publish-status-classification.test.ts b/packages/rest/src/package-publish-status-classification.test.ts index df8993bc26..aecb2df803 100644 --- a/packages/rest/src/package-publish-status-classification.test.ts +++ b/packages/rest/src/package-publish-status-classification.test.ts @@ -394,12 +394,15 @@ describe('[#8131 / #8132] the predicate now judges this phrasing — and the ret describe('[#8131] the producer re-throws exactly what the shared rule can map', () => { /** - * `declaresHttpAnswer` keys on the STATUS channel — `.status` or - * `.statusCode` — and deliberately not on `.code`. 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. + * `declaredStatus` keys on the STATUS channel — `.status` or `.statusCode` + * — and deliberately not on `.code`. Delegates to the shared rule's own + * `ThrownHttpError.declaredStatus` field (#8634) rather than hand-spelling + * the sentinel trick this used to probe with: present exactly when the + * throw declared a status of its own, absent when it did not — including + * the one case a `fallbackStatus`-probe cannot tell apart, a producer that + * declares `0`. */ - const declaredStatus = (error: unknown) => resolveThrownHttpError(error, 0).status !== 0; + const declaredStatus = (error: unknown) => resolveThrownHttpError(error).declaredStatus !== undefined; const SHAPES: Array<{ name: string; error: unknown; rethrown: boolean }> = [ { name: '.status', error: Object.assign(new Error('x'), { status: 409 }), rethrown: true }, @@ -433,10 +436,10 @@ describe('[#8131] the producer re-throws exactly what the shared rule can map', }); // The shared rule does record it… - const resolved = resolveThrownHttpError(driverError, 0); + const resolved = resolveThrownHttpError(driverError); expect(resolved.declaredCode).toBe('ERR_SQLITE_ERROR'); // …while declaring NO status of its own, which is the signal that counts. - expect(resolved.status).toBe(0); + expect(resolved.declaredStatus).toBeUndefined(); expect(declaredStatus(driverError)).toBe(false); // And had it been re-thrown, the door would have resolved it as an