Skip to content

feat(errors): register the platform billing error codes - #1865

Merged
pyramation merged 2 commits into
mainfrom
feat/billing-error-codes
Oct 2, 2026
Merged

pyramation merged 2 commits into
mainfrom
feat/billing-error-codes

Conversation

@yyyyaaa

@yyyyaaa yyyyaaa commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The constructive-db billing rework (constructive-io/constructive-db#3904) raises new database error codes. This registers them, so errorEnvelope and the gateway return their proper HTTP status instead of treating them as unknown.
  • The registry is regenerated with scripts/audit-db-errors.py. The public entries are curated in src/registry.ts.

Codes

Code Class Status Context Raised by
BILLING_SUBSCRIPTION_ACTIVE public 409 { entity_id, external_subscription_id } the generated BEFORE DELETE guard: deleting an org or user that still has a live subscription
BILLING_QUOTA_EXCEEDED public 429 none the LimitTrackUsage gate trigger, when a row would pass the usage allowance (already on db main, previously unregistered)
BILLING_CHECKOUT_BINDING_INVALID internal 500 { entity_id, operation_id } bind_checkout_session, a system-only seam, called with a null id (a caller bug)
BOOTSTRAP_OWNER_NOT_ACTIVE, SCHEDULED_JOB_NOT_ENQUEUED internal 500 as raised db main, newer than the last snapshot

FREE_PLAN_REQUIRED is dropped, because the rework no longer raises it.

// a P0001 with DETAIL {"code":"BILLING_SUBSCRIPTION_ACTIVE","class":"public",...}
httpStatusFor(parse(err)); // 409

Merge order

Merge after constructive-io/constructive-db#3904. Before merging, re-run scripts/audit-db-errors.py against the merged db main: this snapshot was taken from the db branch, so newer db-main codes may be missing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BqoF2inmLL6xPNjX1JiqXx

…TIVE, BILLING_QUOTA_EXCEEDED)

Re-audited constructive-db feat/platform-billing-generic (69a1913ffc8) and
regenerated the registry; curated public copy for the deletion guard's
BILLING_SUBSCRIPTION_ACTIVE (409) and the usage gate's BILLING_QUOTA_EXCEEDED
(429). The same audit adds the internal BILLING_CHECKOUT_BINDING_INVALID,
BOOTSTRAP_OWNER_NOT_ACTIVE and SCHEDULED_JOB_NOT_ENQUEUED, and drops
FREE_PLAN_REQUIRED, which the billing branch no longer raises.
@tenki-reviewer

tenki-reviewer Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR extends the shared error registry with two billing-related codes: BILLING_QUOTA_EXCEEDED mapped to HTTP 429 and BILLING_SUBSCRIPTION_ACTIVE mapped to HTTP 409 with optional entity/external-subscription context, alongside a new test suite asserting their inventory presence and HTTP mappings. A review pass — including a sweep that initially suspected a missing BILLING_CHECKOUT_BINDING_INVALID definition — confirmed the generated registry already provides that code, so all assertions hold. No defects were found.

Files Change
packages/errors/src/registry.ts Adds curated defineError entries for the two new billing codes.
packages/errors/__tests__/billing-refusals.test.ts New tests covering raised-code parsing, inventory alignment, and HTTP status mapping.
packages/errors/scripts/db-error-inventory.json Regenerated inventory reflecting the new codes.

Reviewed commit: fc65ee6

…ory and registry against constructive-db#3904
@pyramation
pyramation merged commit a6e2018 into main Oct 2, 2026
20 checks passed
@pyramation
pyramation deleted the feat/billing-error-codes branch October 2, 2026 00: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.

2 participants