Repository navigation
refactor(errors): remove deprecated HTTP_ERROR_CODES map - #2039
Closed
liutingqiu wants to merge 1 commit into
Closed
liutingqiu wants to merge 1 commit into
liutingqiu wants to merge 1 commit into
Conversation
HTTP_ERROR_CODES duplicated the HTTP status to error-code mapping that ERROR_CODE_REGISTRY already owns in errorCodes.ts. It was marked @deprecated and had no consumers outside its own test, so it only widened the surface a contributor had to reason about when picking a source of truth. Drop the map and replace its test block with coverage that asserts the export is gone and that ERROR_CODE_REGISTRY stays the single source of truth.
|
@liutingqiu is attempting to deploy a commit to the 1nonly's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Payment details: Stellar: GB2BHZX2SGCNNQVNC3CWSEHGWWJFIARVLDRAHED4IACUKRI5UCWZRN5R. Fiat payments: PayPal: tianqi689@gmail.com. |
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.
Context
src/lib/backend/errors.tscarried a second,@deprecatedmap of HTTP status codes to error-code strings:ERROR_CODE_REGISTRYinerrorCodes.tsalready owns this mapping and carries the extra documentation the deprecated map lacks (meaning, client handling,retriable,statusCode). Keeping the deprecated copy means two answers to "which error-code source of truth do I use?", and the deprecated one has no application consumer — a repo-wide code search forHTTP_ERROR_CODESreturns only its own definition, its own test, and a historical patch file under the repo root.errors.tshas no barrel to update:src/lib/backend/index.ts(referenced in the issue) no longer exists in the tree, and the file is only ever imported directly.What changed
HTTP_ERROR_CODESdeclaration and its “HTTP status → error code mapping” section fromsrc/lib/backend/errors.ts(−25 lines). Nothing else in the file referenced it.src/lib/backend/errors.test.tswith two that lock in the outcome:'HTTP_ERROR_CODES' in errorsModuleisfalse), so it cannot silently come back;errors.ts's re-exportedERROR_CODE_REGISTRYis the same object as the one inerrorCodes.ts, i.e. registry remains the single source of truth.No behaviour change: the removed constant was not read by any application code path.
How to verify
npm ci npx vitest run src/lib/backend/errors.test.ts # 37 passed npm run format:check npx tsc --noEmitLocal results on this branch (Windows,
node v24.21.0, i.e. not the pinned Node 20 from.nvmrc):src/lib/backend/errors.test.ts: 37/37 pass, including the two new assertions.npm run format:checkon the two touched files: clean (Prettier applied).npx eslinton the two touched files: clean.npx tsc --noEmit: 58 errors, identical to the count on unmodifiedmasterin the same environment; none are inerrors.tsorerrors.test.ts. The job iscontinue-on-error: truein CI while the pre-existing backlog is burned down (seedocs/CI.md).npm run test:coverageon unmodifiedmasterin this environment: 43 files failed / 163 tests failed, and on this branch: the same 43 files / the same 163 tests failed. The only delta is theerrors.test.tscount itself (38 → 37, matching 3 removed + 2 added). I could not reproduce the repo's pinned Node 20 here, so those 163 failures are environmental/pre-existing rather than caused by this change; CI on Node 20 is the authoritative run.Notes
No new logic was added, so the 95% coverage expectation for changed logic does not apply; removing dead lines can only improve the coverage ratio for
src/lib/backend/**.Closes #1937