Repository navigation
fix(billing): release audit follow-ups for v0.9.66 billing - #10457
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The PR appears safe to merge; no new actionable issues remain. SummaryThis PR fixes payment recovery and makes plan switches read the subscription and usage pool together.
The earlier downgrade-retry finding is fixed. waleedlatif1 accepted the seat-sync behavior as intentional because seat sync only raises the limit to the plan-plus-credit floor; it does not preserve a fixed amount of spending room above that floor. No new actionable issues were found. Tests were inspected but not run. Reviews (3) · Last reviewed commit: "fix(billing): price a retried switch's o..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 10 files
This PR changes payment, billing, or quota logic. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Turn on auto-fix | Re-trigger cubic
0297579 to
6b6da31
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
3 issues found across 10 files
Confidence score: 3/5
- In
invoices.ts, a member’s personal or other-organizationpayment_failedrow can be mistaken for this organization’s block, so a successful invoice may clear the wrong block. Match the row to the organization’s subscription before unblocking. - In
switch-plan/route.ts, a subscription transfer between the scope check andrecordPlanSwitchcan leave the route using stale organization scope and pool data. Revalidate the subscription before recording the switch. - In
invoices.integration.ts, the paid-invoice fixture does not match the subscription’s Stripe customer, and the mock ignores the customer filter. Use the fixture customer so this test can catch customer-filtering regressions.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/billing/webhooks/invoices.integration.ts">
<violation number="1" location="apps/sim/lib/billing/webhooks/invoices.integration.ts:92">
P2: This fixture does not associate the paid invoice with the subscription's Stripe customer, and the mocked listing ignores its customer filter. Return the fixture customer from `createTeam` and use it in `paidOverageInvoice`, then assert the listing receives that customer so this integration test models the production invoice relationship.</violation>
</file>
<file name="apps/sim/lib/billing/webhooks/invoices.ts">
<violation number="1" location="apps/sim/lib/billing/webhooks/invoices.ts:650">
P1: This check cannot distinguish an organization block from a `payment_failed` row created by a member’s personal or different organization subscription. A successful invoice for this organization can therefore call `unblockOrgMembers` and restore access while the unrelated invoice is still unpaid; scope the block source to the payer/subscription before deciding which rows to clear.</violation>
</file>
<file name="apps/sim/app/api/billing/switch-plan/route.ts">
<violation number="1" location="apps/sim/app/api/billing/switch-plan/route.ts:240">
P2: `basis.subscription` can be re-homed after the initial scope check, but this route still passes the old `orgScoped` and pool snapshot into `recordPlanSwitch`. If a subscription transfer commits between those reads, the switch updates the plan while rebasing the wrong usage pool, leaving the actual allowance stale; validate the reference/scope in the snapshot or reject a re-homed basis before recording.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
- a paid invoice unblocks every member still blocked for payment, not only when the org owner is - a plan switch reads the subscription and its usage pool in one snapshot under its claim, so a seat sync cannot price one seat count against a limit set for another - a hosted-key plan check that cannot read the balance fails with a plain message, not the raw database error - the Team-during-trial message covers a canceled trial
A seat sync takes no switch claim and can land while Stripe applies the change, so the new allowance comes from the subscription row locked in the recording transaction. The integration fixture builds its event with the shared Stripe event helper.
… left A retry finds the subscription webhook may already have recorded the new plan, so the old allowance always comes from the request's plan and interval, with the locked seat count for the live limit. A switch is refused when the subscription moved to another payer since it was read. The invoice fixture pays from the subscription's own Stripe customer.
6b6da31 to
6524d22
Compare
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
Type of Change
Testing
lib/billing/webhooks/invoices.integration.ts(3): owner already unblocked, another invoice still failing, nobody blocked skips the Stripe listing. The first fails on the current staginginvoices.tsplan-allowance.integration.ts(25), including a new case for a seat added after the request read the plan, which fails when the switch computes from the stale readinvoices.test.ts,access.test.ts,tools/index.test.ts,switch-plan/route.test.ts,authorization.test.ts,byok.test.ts(334 passed)check:test-patterns,check:source-conventions,check:comment-hygiene,check:explicit-anyChecklist
test-auditauthoring gate)