feat(errors): canonical code -> HTTP status resolver, loud on unmapped codes - #1643
Merged
Conversation
…codes httpStatusFor(code) is now the one place a transport asks for a status, and an unregistered code is reported once instead of quietly answering 500. Refreshes the constructive-db audit snapshot: 15 codes raised on main were missing from the registry, so each of them was already surfacing as a 500.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
constructive-planning#1415reported that every HTTP surface keeps its own error-code → status table, soACCOUNT_DISABLEDis a 403 in one place and a 500 in another. The mapping already existed — every registry entry carrieshttp— so the actual defect is narrower and worse: a code that never reached the registry answers 500 with no signal, which is indistinguishable from a crash.Two changes:
1. One resolver, and unmapped is loud (
src/http.ts):toError()routes its fallback through it, so the transport path reports too:2. The registry was 3 days stale, which is how the gap got reported. Re-running the audit against
constructive-db@mainfound 15 codes raised there that the registry doesn't know —SUBDOMAIN_APEX_NOT_PUBLISHED,APP_INSTALL_NO_SERVICE,STATIC_SITES_LIMIT,DATABASE_CLAIM_REQUIRED, theDATA_HISTORY_*family, … — every one of them a silent 500 today. Refreshed the snapshot + regenerated (531 → 546 codes), and added__tests__/registry-sync.test.tsso an inventory refreshed without a regeneration (or vice versa) fails here rather than in production.One existing expectation in
parse.test.tshad to shrink:STEP_UP_REQUIRED_PASSWORD_OR_MFAis genuinely gone from constructive-db (616a2aefc14split it into the per-factorSTEP_UP_REQUIRED_PASSWORD/_MFA/_FRESH_AUTHcodes, all still 403), so asserting it exists was asserting a stale snapshot.Not addressed here: the cross-repo drift that caused this needs the audit re-run when constructive-db adds codes. This test only catches drift between the committed snapshot and the generated file, not between the snapshot and constructive-db — that needs a CI job with both checkouts, and belongs in the #1415 follow-up rather than in this package.
packages/errorstests: 39 passing.Link to Devin session: https://app.devin.ai/sessions/087553534c774929918ec4d378845881
Requested by: @pyramation