Skip to content

feat(errors): register verified-only identifier claim error codes - #1849

Merged
pyramation merged 1 commit into
mainfrom
feat/identifier-claim-error-codes
Sep 19, 2026
Merged

pyramation merged 1 commit into
mainfrom
feat/identifier-claim-error-codes

Conversation

@pyramation

Copy link
Copy Markdown
Contributor

Summary

Registers the application error codes introduced by constructive-io/constructive-db#3830 (verified-only uniqueness for emails/phone_numbers) in @constructive-io/errors, so clients get typed, human copy instead of raw codes.

Workflow followed: audit-db-errors.py against constructive-db main (post-#3830) → generate-registry.py → curated overlay in src/registry.ts. The generated file is untouched by hand; the inventory contains no constructive-db paths (verified with a grep).

Codes from #3830 (curated, class public)

code http context
IDENTIFIER_VERIFIED_ELSEWHERE 409
IDENTIFIER_UNVERIFIED_AMBIGUOUS 409
IDENTIFIER_CLAIM_LIMIT 429 { limit?: number } (SQL passes jsonb_build_object('limit', …))
MFA_IDENTIFIER_UNVERIFIED 403
SMS_VERIFICATION_DISABLED 403

TOO_MANY_REQUESTS was already curated and is unchanged.

Unrelated new codes picked up by the re-audit (from other recent constructive-db merges)

Billing provider / metering (ast-plpgsql billing helpers): BILLING_ENTITY_BUSY, BILLING_NOT_READY, BILLING_OPERATION_CONFLICT, BILLING_OPERATION_INVALID, UNKNOWN_METER are raised as public in SQL, so they get curated copy + typed context (entity_id, operation_id, meter_slug, …). The remaining ones are internal/generated-only and rely on the generated registry: BILLING_HEALTH_INVALID, BILLING_OBSERVATION_INVALID, BILLING_OPERATION_NOT_FOUND, BILLING_OPERATION_SETTLED, BILLING_OPERATION_STATE_INVALID, BILLING_RECONCILE_BOUNDS_REQUIRED, BILLING_SCHEDULED_CHANGE_INVALID, AST_OPTIONS_NOT_OBJECT, AST_OPTION_REQUIRED, AST_OPTION_UNKNOWN.

Note on the inventory

The fresh audit no longer finds the seven STORAGE_* lifecycle codes (they are not in the constructive-db corpus the script scans), but __tests__/storage-lifecycle.test.ts pins them as a package contract, so their existing inventory records were preserved rather than dropped. Flagging in case that contract should instead be revisited.

Tests

New __tests__/identifier-claims.test.ts asserts the five identifier/MFA/SMS codes are audited, generated, public, carry the expected HTTP status and human copy, and that limit flows through toError DETAIL context. pnpm build, pnpm lint, pnpm test (51 tests) pass in packages/errors. No version bump.

Link to Devin session: https://app.devin.ai/sessions/89010f9efacf4d4e904f838a55bec28c
Open in Devin Desktop: https://app.devin.ai/desktop/session/89010f9efacf4d4e904f838a55bec28c?variant=devin
Requested by: @pyramation

…ER_VERIFIED_ELSEWHERE, IDENTIFIER_UNVERIFIED_AMBIGUOUS, IDENTIFIER_CLAIM_LIMIT, MFA_IDENTIFIER_UNVERIFIED)

Re-audited constructive-db main (post #3830) and regenerated the registry;
curated public copy for the identifier/MFA/SMS codes and the new public
billing-provider codes picked up by the same audit.
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@tenki-reviewer

tenki-reviewer Bot commented Sep 19, 2026

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This change extends the error registry in packages/errors with a new identifier-claiming/verification error family (verified-elsewhere, unverified-ambiguous, claim-limit, MFA-unverified, SMS-disabled) plus a billing-metering family (not-ready, entity-busy, operation-conflict/invalid, unknown-meter). It also updates the db-error-inventory and adds a test that asserts the HTTP status, error class, and message pattern for the identifier-claim codes. All candidates raised during review were design/UX preferences on brand-new codes with no surviving repo evidence of a functional defect, and the status-code choices consistently match existing registry conventions (e.g. quota/limit codes are 429).

Files Change
packages/errors/src/registry.ts Adds identifier-verification and billing error definitions with HTTP statuses, classes, and typed context.
packages/errors/scripts/db-error-inventory.json Registers the new error codes and updates occurrence/source counts.
packages/errors/__tests__/identifier-claims.test.ts New tests verifying the identifier-claim error statuses, classes, and message patterns.

Reviewed commit: c2bc7a6

@pyramation
pyramation merged commit 0ccf71f into main Sep 19, 2026
21 checks passed
@pyramation
pyramation deleted the feat/identifier-claim-error-codes branch September 19, 2026 01:34
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.

1 participant