Repository navigation
fix(billing): refuse self-serve Enterprise checkout with a client error - #10469
Conversation
Enterprise is issued by the team with its own Stripe price and metadata. A self-serve upgrade naming it wrote the plan onto a pending subscription row, which the Enterprise metadata constraint rejected, and the caller got a 500. The checkout hook now refuses it with a 400 before taking the admission claim.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The change is limited to the self-serve subscription checkout path. Normalize the Enterprise plan name before merging so changing its case cannot bypass the new refusal. Findings
SummaryAdds an early Enterprise refusal to
Reviews (2) · Last reviewed commit: "fix(billing): refuse self-serve Enterpri..." · Reviewed by Greptile |
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
| * and its write to a pending subscription row fails the Enterprise metadata constraint. | ||
| */ | ||
| export function assertSelfServeCheckoutPlan(plan: unknown): void { | ||
| if (typeof plan !== 'string' || !isEnterprise(plan)) return |
There was a problem hiding this comment.
Mixed-case Enterprise bypasses refusal
assertSelfServeCheckoutPlan only rejects lowercase enterprise because isEnterprise uses exact equality. A personal checkout with plan: 'Enterprise' or 'ENTERPRISE' passes this guard, but the Stripe plugin accepts either spelling. Enterprise remains in getPlans(), so the pending subscription write fails the database's Enterprise metadata check and returns a server error instead of the intended 400.
Normalize the name before checking it and add mixed-case regression tests.
| if (typeof plan !== 'string' || !isEnterprise(plan)) return | |
| if (typeof plan !== 'string' || !isEnterprise(plan.trim().toLowerCase())) return |
Summary
/subscription/upgrade) now refusesplan: 'enterprise'with a 400 before taking the checkout admission claimenterpriseonto a pending subscription row failed thecheck_enterprise_metadataconstraint, so the caller got a 500Type of Change
Testing
lib/billing/authorization.test.ts: Enterprise refused with a 400, Pro and Team admitted. The refusal case fails with the guard removedcheck:api-validation:strict,check:test-patternsChecklist
test-auditauthoring gate)