Skip to content

rest: a declared 5xx answers 500 ANALYTICS_QUERY_FAILED on /analytics/dataset/query where /data answers the declared status and code #11718

Description

@os-zhuang

Filed unassigned while implementing the #11683 + #11684 fold. Out of scope there: both cards are about the 4xx band, and moving the 5xx arm is a separate contract call on a shipped route.

Measured

Found by the first draft of rest-hook-refusal-message-parity.test.ts §8e, which included this case in its door-to-door parity loop and reddened with the #11684 fix in place. Both handlers driven in process, one error object, on claude/issue-11683-route-refusal-classification:

faceanswer
POST /api/v1/data/:object503{"error":"Internal server error","code":"SERVICE_UNAVAILABLE"}
POST /api/v1/analytics/dataset/query500{"code":"ANALYTICS_QUERY_FAILED","error":"Internal server error"}

The error is a producer-declared server fault: { code: 'SERVICE_UNAVAILABLE', status: 503 }.

Now pinned as measured-and-not-repaired in that file's §8f, so the bound on §8e's parity claim is visible rather than implied.

Why

resolveErrorResponse's passthrough (#5582) keeps a declared 5xx's status and code and drops only the prose — the ruling's own argument being that 502/503 are isExpectedDataStatus lifecycle outcomes that proxies and retry policies read differently from a 500, so collapsing them onto 500 destroys the declaration to protect the message.

The analytics catch's arm ① is 4xx-only by design, so a declared 5xx falls to ③'s hand-built 500 ANALYTICS_QUERY_FAILED. Both halves of that are deliberate and documented (#5352, re-argued by #5367 and #5811, and load-bearing for read-scope-sql's ten READ_SCOPE_COMPILE_FAILED refusals) — but the ruling was about withholding the message, and the status collapse rides along with it. The prose half already agrees: both faces answer INTERNAL_ERROR_MESSAGE.

Not established here

Region: packages/rest/src/rest-server.ts, the /analytics/dataset/query catch's arm ③ only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions