Skip to content

Release dev to main - #2307

Merged
johnyeocx merged 19 commits into
mainfrom
dev
Jul 20, 2026
Merged

Release dev to main#2307
johnyeocx merged 19 commits into
mainfrom
dev

Conversation

@charlietlamb

@charlietlamb charlietlamb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary by cubic

Adds scalable, batched license transitions and cycle alignment to support large pool updates without timeouts, plus parent→child license propagation that preserves customizations in catalog updates. Also fixes variant customize row-ID collisions by stripping base-plan row IDs and disables lazy migration runs so dashboard-triggered runs execute immediately.

  • New Features

    • Batched license transitions: base-price and entitlement operations, cycle alignment, and batch-transition task with timeouts, concurrency, and safety limits.
    • Billing computes: per-price line items merged, projected seat rows priced via incoming definitions, improved unused-prepaid math, next-cycle preview includes scheduled paid products, and patched updates inherit subscription_ids.
    • Safer attach/update: centralized compute error handling and validation of license transitions, attach-target validation for child licenses, dropped-license checks with successor matching, and quantity setup that retains omitted 1:1 successors.
    • Catalog: parent license propagation (target resolution, preserved customizations, snapshots) wired into preflight and updateCatalog; dependency sorting simplified.
  • Bug Fixes

    • Align entitlement cycles for reassigned seats; seat queries rank by the parent’s live status.
    • Correct recurring base-price repoints in license transitions and exclude orphan recurring items from Stripe updates.
    • Keep subscription_ids in sync when adding/removing Stripe subscriptions across updated customer products.

Written for commit f4f3575. Summary will update on new commits.

Review in cubic

Greptile Summary

This PR ships two independent fixes from the dev branch: a server-side bug fix that prevents duplicate-key DB errors when catalog variants inherit unchanged base plan rows, and a migration UI simplification that permanently disables lazy execution.

  • [Bug fixes] stripPlanRowIds strips entitlement_id and price_id from a base plan's price and items before it seeds a variant, preventing duplicate key ... "entitlements_id_key" constraint violations on catalog.update. Both the write path (updateVariants) and the preview path (previewAffectedVariants) are patched, and a new integration test covers the idempotent re-push case that originally surfaced the bug.
  • [Bug fixes / Improvements] buildRunMigrationRequest is extracted as a pure, testable function that hard-codes lazy_run: false, and the "Lazy run" admin toggle is removed from MigrationLiveView. Previously, full (non-targeted) migration runs defaulted to lazy_run: true; they now always run eagerly.

Confidence Score: 5/5

Safe to merge — both changes are tightly scoped bug fixes with accompanying tests, and the lazy-run removal is an intentional product decision reflected consistently across the server, hook, and UI layers.

The stripPlanRowIds fix is straightforward and correctly applied in both the write and preview paths; the integration test covers the original crash scenario and its idempotent re-push variant. The lazy_run: false hardcoding and UI removal are consistent with each other and with the new unit tests. No logic gaps or unintended side effects were found.

No files require special attention.

Important Files Changed

Filename Overview
server/src/internal/product/actions/common/planTransformUtils.ts Adds stripPlanRowIds helper that removes entitlement_id and price_id from a plan's price and items before seeding a variant, fixing a duplicate-key DB constraint.
server/src/internal/product/actions/updateVariants/updateVariants.ts Applies stripPlanRowIds to incomingBasePlan before building the variant target plan, preventing entitlement/price row ID collisions on upsert.
server/src/internal/product/actions/previewUpdatePlan/previewAffectedVariants.ts Applies stripPlanRowIds to the edited base plan before computing the variant preview, consistent with the fix in updateVariants.
server/tests/integration/crud/catalog/catalog-variant-inherited-item.test.ts New integration test reproducing the duplicate-key bug; verifies variant owns distinct entitlement/price IDs and correct allowances on both first and idempotent catalog updates.
vite/src/views/migrations/migration/hooks/buildRunMigrationRequest.ts New pure function that builds the migration run request payload, always setting lazy_run: false and defaulting targeted runs to retry_item_statuses: ["failed"].
vite/src/views/migrations/migration/hooks/useRealtimeSubscriptions.ts Refactored to delegate request construction to buildRunMigrationRequest; removes the lazyRun parameter from triggerRun, permanently disabling lazy execution.
vite/src/views/migrations/migration/live/MigrationLiveView.tsx Removes the "Lazy run" toggle from the admin run controls UI and its backing state, consistent with the forced lazy_run: false in buildRunMigrationRequest.
vite/tests/views/migrations/migration/build-run-migration-request.test.ts Unit tests for buildRunMigrationRequest covering the base case and targeted-run retry-status defaulting; confirms lazy_run is always false.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Caller
    participant updateVariants
    participant stripPlanRowIds
    participant applyDiffToVariantPlan
    participant DB

    Caller->>updateVariants: catalog.update(params)
    updateVariants->>updateVariants: fetch incomingBasePlan (has entitlement_id / price_id)
    updateVariants->>stripPlanRowIds: "stripPlanRowIds({ plan: incomingBasePlan })"
    stripPlanRowIds-->>updateVariants: plan without entitlement_id / price_id
    updateVariants->>applyDiffToVariantPlan: "applyDiffToVariantPlan({ plan: stripped, diff })"
    applyDiffToVariantPlan-->>updateVariants: variantTargetPlan (no conflicting row ids)
    updateVariants->>DB: "upsert variant entitlements & prices (mints new ids)"
    DB-->>updateVariants: success (no duplicate key error)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Caller
    participant updateVariants
    participant stripPlanRowIds
    participant applyDiffToVariantPlan
    participant DB

    Caller->>updateVariants: catalog.update(params)
    updateVariants->>updateVariants: fetch incomingBasePlan (has entitlement_id / price_id)
    updateVariants->>stripPlanRowIds: "stripPlanRowIds({ plan: incomingBasePlan })"
    stripPlanRowIds-->>updateVariants: plan without entitlement_id / price_id
    updateVariants->>applyDiffToVariantPlan: "applyDiffToVariantPlan({ plan: stripped, diff })"
    applyDiffToVariantPlan-->>updateVariants: variantTargetPlan (no conflicting row ids)
    updateVariants->>DB: "upsert variant entitlements & prices (mints new ids)"
    DB-->>updateVariants: success (no duplicate key error)
Loading

Reviews (1): Last reviewed commit: "Merge pull request #2302 from useautumn/..." | Re-trigger Greptile

johnyeocx and others added 16 commits July 17, 2026 16:43
Add license parent preview and propagation controls, preserve customer
configurations across catalog updates, and organize core license catalog
coverage.
Mock the license-reference collaborators added to product item updates
so existing atomicity and lock tests exercise their intended paths.
…ement-ids

fix(catalog): variant customize inherits base plan entitlement ids
@capy-ai

capy-ai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
checkout Ignored Ignored Jul 20, 2026 2:44pm
landing-page Ignored Ignored Jul 20, 2026 2:44pm

Request Review

@mcp-use

mcp-use Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deployment #729 deployment failed

StatusLogsURLURLUpdated
FailedBuild Logs | Runtime Logs🔗 ProductionN/AJul 20 2026 2:43 pm

View deployment details


Deployed on Manufact.com

@johnyeocx
johnyeocx merged commit d4593b1 into main Jul 20, 2026
18 of 20 checks passed
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.

3 participants