Skip to content

fix: avoid reinserting pending custom catalog rows - #3225

Merged
charlietlamb merged 1 commit into
mainfrom
hotfix/pending-custom-price-duplicate
Sep 2, 2026
Merged

fix: avoid reinserting pending custom catalog rows#3225
charlietlamb merged 1 commit into
mainfrom
hotfix/pending-custom-price-duplicate

Conversation

@charlietlamb

@charlietlamb charlietlamb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • omit custom prices, entitlements, and free trials already persisted by the pending path before executing the promoted plan
  • cover a custom-price Stripe Checkout through both Autumn webhook deliveries

Red / green

  • RED on main: checkout completed, but customer.products.updated was null after 30s because prices_id_key crashed the handler
  • GREEN with fix: checkout completed and both billing.updated and customer.products.updated arrived; 1 test passed, 0 failed
  • bunx tsgo --build --noEmit
  • biome check on both changed files

Summary by cubic

Fixes custom-price Stripe Checkouts crashing on completion by omitting pending custom catalog rows when promoting a pending plan.

  • Previously the promoted plan reinserted custom prices, entitlements, and free trials already persisted by the pending path, causing a prices_id_key constraint crash before webhooks fired.
  • Updates the integration test to cover a custom-price checkout and verify both billing.updated and customer.products.updated webhook deliveries.

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

Review in cubic

Greptile Summary

This PR prevents checkout completion from attempting to insert custom catalog rows that were already stored when the purchase became pending.

  • Bug fixes: Removes persisted custom prices, entitlements, and free-trial definitions from the promoted execution plan, preventing duplicate insertion failures.
  • Improvements: Extends the checkout integration scenario to verify that a custom-price purchase emits both billing and customer-product webhooks.

Confidence Score: 5/5

The PR appears safe to merge, with the custom-row suppression matching the pending-plan persistence lifecycle.

Pending creation stores the complete set of custom catalog rows before checkout, and the promotion path now avoids inserting those same rows again while preserving all remaining customer-product actions.

Important Files Changed

Filename Overview
server/src/internal/billing/v2/execute/promotePendingCustomerProducts.ts Prevents promoted pending plans from reinserting custom catalog records that were persisted during pending-plan creation.
server/tests/integration/billing/autumn-webhooks/billing-updated/billing-updated-attach.test.ts Updates checkout coverage to exercise a custom price and require both billing and customer-product webhook deliveries.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Checkout
    participant DB
    participant Stripe
    participant Webhook
    Client->>Checkout: Attach custom-price plan
    Checkout->>DB: Persist custom rows and pending product
    Checkout->>Stripe: Create checkout session
    Stripe-->>Checkout: Checkout completed
    Checkout->>DB: Promote pending product
    Note over Checkout,DB: Omit already-persisted custom rows
    Checkout->>DB: Execute remaining billing actions
    Checkout->>Webhook: Send billing.updated
    Checkout->>Webhook: Send customer.products.updated
Loading

Reviews (1): Last reviewed commit: "fix: avoid reinserting pending custom ca..." | Re-trigger Greptile

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Actions Updated
checkout Ignored Ignored Sep 2, 2026 5:11pm UTC
landing-page Ignored Ignored Sep 2, 2026 5:11pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – autumn-vite September 2, 2026 17:11 Inactive
@charlietlamb
charlietlamb merged commit 0e14fbc into main Sep 2, 2026
30 checks passed
@charlietlamb
charlietlamb deleted the hotfix/pending-custom-price-duplicate branch September 2, 2026 17:14
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.

1 participant