Skip to content

refactor(errors): remove deprecated HTTP_ERROR_CODES map - #2039

Closed
liutingqiu wants to merge 1 commit into
Commitlabs-Org:masterfrom
liutingqiu:fix/1937-remove-http-error-codes
Closed

liutingqiu wants to merge 1 commit into
Commitlabs-Org:masterfrom
liutingqiu:fix/1937-remove-http-error-codes

Conversation

@liutingqiu

Copy link
Copy Markdown

Context

src/lib/backend/errors.ts carried a second, @deprecated map of HTTP status codes to error-code strings:

/** @deprecated Use ERROR_CODE_REGISTRY from errorCodes.ts ... */
export const HTTP_ERROR_CODES: Record<number, string> = { 400: 'BAD_REQUEST', ... };

ERROR_CODE_REGISTRY in errorCodes.ts already 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 for HTTP_ERROR_CODES returns only its own definition, its own test, and a historical patch file under the repo root.

errors.ts has 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

  • Removed the HTTP_ERROR_CODES declaration and its “HTTP status → error code mapping” section from src/lib/backend/errors.ts (−25 lines). Nothing else in the file referenced it.
  • Replaced the three tests that asserted the map's contents in src/lib/backend/errors.test.ts with two that lock in the outcome:
    • the deprecated export is no longer present on the module ('HTTP_ERROR_CODES' in errorsModule is false), so it cannot silently come back;
    • errors.ts's re-exported ERROR_CODE_REGISTRY is the same object as the one in errorCodes.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 --noEmit

Local 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:check on the two touched files: clean (Prettier applied).
  • npx eslint on the two touched files: clean.
  • npx tsc --noEmit: 58 errors, identical to the count on unmodified master in the same environment; none are in errors.ts or errors.test.ts. The job is continue-on-error: true in CI while the pre-existing backlog is burned down (see docs/CI.md).
  • Full npm run test:coverage on unmodified master in 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 the errors.test.ts count 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

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.
@vercel

vercel Bot commented Oct 1, 2026

Copy link
Copy Markdown

@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.

@liutingqiu

Copy link
Copy Markdown
Author

Payment details: Stellar: GB2BHZX2SGCNNQVNC3CWSEHGWWJFIARVLDRAHED4IACUKRI5UCWZRN5R. Fiat payments: PayPal: tianqi689@gmail.com.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP_ERROR_CODES in src/lib/backend/errors.ts is @deprecated and effectively dead code

2 participants