fix(billing): allow dropped license pools to transition - #2351
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
|
Capy auto-review is paused for this organization because the usage-cycle auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
| }); | ||
|
|
||
| for (const { outgoingCustomerLicense, reason, group } of unmatched) { | ||
| if (reason === "dropped") continue; |
There was a problem hiding this comment.
Attach Leaves Assignments Active
An immediate attach that drops a pool with assigned seats now passes this guard, but only the sync planner creates releaseCustomerLicenseAssignments. The attach planner handles matched license transitions and has no release action for this unmatched pool, so the old product can expire while its entity assignments remain active.
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/internal/billing/v2/actions/attach/errors/handleLicenseErrors/handleDroppedLicenseErrors.ts
Line: 29
Comment:
**Attach Leaves Assignments Active**
An immediate attach that drops a pool with assigned seats now passes this guard, but only the sync planner creates `releaseCustomerLicenseAssignments`. The attach planner handles matched license transitions and has no release action for this unmatched pool, so the old product can expire while its entity assignments remain active.
How can I resolve this? If you propose a fix, please make it concise.965bf75 to
28637a9
Compare
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Confidence score: 3/5
- In
server/src/internal/billing/v2/actions/attach/errors/handleLicenseErrors/handleDroppedLicenseErrors.ts, the newif (reason === "dropped") continuepath appears to let dropped pools with active assignments proceed in attach while the downstream release path (computeCustomerLicenseReleases/executeCustomerLicenseReleases) does not account for dropped pools, which can leave assignments/licenses out of sync for customers after merge. Align the attach guard with the release logic (or add explicit dropped-pool handling there) and cover it with a regression test before merging.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="server/src/internal/billing/v2/actions/attach/errors/handleLicenseErrors/handleDroppedLicenseErrors.ts">
<violation number="1" location="server/src/internal/billing/v2/actions/attach/errors/handleLicenseErrors/handleDroppedLicenseErrors.ts:29">
P1: This guard now allows dropped pools with active assignments to pass through in the attach flow (`if (reason === "dropped") continue`), but the compensating release logic (`computeCustomerLicenseReleases` / `executeCustomerLicenseAssignmentReleases`) is only wired into the sync planner. When an immediate attach drops a pool that has assigned seats, the old product will expire while its entity assignments remain active — effectively orphaning them. Either the attach planner needs its own release step for dropped pools, or this guard should remain for the attach path.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| }); | ||
|
|
||
| for (const { outgoingCustomerLicense, reason, group } of unmatched) { | ||
| if (reason === "dropped") continue; |
There was a problem hiding this comment.
P1: This guard now allows dropped pools with active assignments to pass through in the attach flow (if (reason === "dropped") continue), but the compensating release logic (computeCustomerLicenseReleases / executeCustomerLicenseAssignmentReleases) is only wired into the sync planner. When an immediate attach drops a pool that has assigned seats, the old product will expire while its entity assignments remain active — effectively orphaning them. Either the attach planner needs its own release step for dropped pools, or this guard should remain for the attach path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At server/src/internal/billing/v2/actions/attach/errors/handleLicenseErrors/handleDroppedLicenseErrors.ts, line 29:
<comment>This guard now allows dropped pools with active assignments to pass through in the attach flow (`if (reason === "dropped") continue`), but the compensating release logic (`computeCustomerLicenseReleases` / `executeCustomerLicenseAssignmentReleases`) is only wired into the sync planner. When an immediate attach drops a pool that has assigned seats, the old product will expire while its entity assignments remain active — effectively orphaning them. Either the attach planner needs its own release step for dropped pools, or this guard should remain for the attach path.</comment>
<file context>
@@ -28,20 +26,18 @@ export const handleDroppedLicenseErrors = ({
});
for (const { outgoingCustomerLicense, reason, group } of unmatched) {
+ if (reason === "dropped") continue;
const used = customerLicenseToUsage({
customerLicense: outgoingCustomerLicense,
</file context>
Summary
This unblocks Team → Pro transitions where the incoming plan intentionally removes the team seat pool. Unrelated local work remains stashed.
Summary by cubic
Allow plan transitions that drop license pools by releasing active seat assignments during sync. This unblocks Team → Pro migrations while still blocking ambiguous 1:1 license mapping conflicts.
executeAutumnBillingPlan.computeCustomerLicenseReleasesand integrate intocomputeSyncImmediatePhaseandcomputeSyncPlan.licenseAssignmentRepo.releaseActiveAssignmentsto clear assignments and restore poolremaining.AutumnBillingPlanwithreleaseCustomerLicenseAssignments(schema in@autumn/shared).Written for commit 28637a9. Summary will update on new commits.
Greptile Summary
This PR allows billing transitions to release assignments from dropped license pools. The main changes are:
Confidence Score: 4/5
Immediate attach can leave assignments active after their license pool is dropped.
The dropped-license attach guard and immediate attach-plan computation.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Immediate plan transition] --> B{Transition path} B -->|Sync| C[Compute dropped-pool release] C --> D[Release active assignments] B -->|Attach| E[Allow dropped pool] E --> F[No release action created] F --> G[Old assignments remain active]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(billing): allow dropped license pool..." | Re-trigger Greptile
Context used: