fix: return active scenario for owned free products#756
Open
lutz-grex wants to merge 1 commit intouseautumn:devfrom
Open
fix: return active scenario for owned free products#756lutz-grex wants to merge 1 commit intouseautumn:devfrom
lutz-grex wants to merge 1 commit intouseautumn:devfrom
Conversation
When a customer owns a free product and another free product exists in the same group, getAttachScenario incorrectly returns 'new' instead of 'active'. This happens because curMainProduct matches by group (not exact ID), so it may pick a different product. The fix checks curSameProduct (exact ID match) before returning 'new' in the free-to-free block.
|
@lutz-grex is attempting to deploy a commit to the Autumn Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a customer owns a free product and another free product exists in the same group, getAttachScenario incorrectly returns 'new' instead of 'active'. This happens because curMainProduct matches by group (not exact ID), so it may pick a different product. The fix checks curSameProduct (exact ID match) before returning 'new' in the free-to-free block.
Summary
scenario: 'new'instead ofscenario: 'active'inGET /products_beta, causing the pricing table to miss the "Current Plan" badgegetAttachScenario.ts, the free-to-free check at lines 73-78 always returnsAttachScenario.Newwithout checking if the customer actually owns that specific product viacurSameProductcurSameProduct(exact product ID match) before returningNewin the free-to-free block, consistent with the existing pattern used for paid productsRelated Issues
Type of Change
Checklist
Screenshots (if applicable)
Additional Context
The fix adds 6 lines to
server/src/internal/products/productUtils/productResponseUtils/getAttachScenario.ts. It reuses the existingcurSameProductvariable (already destructured but unused in this code path) and the existingisCustomerProductCancelinghelper to handle the canceling edge case consistently.Summary by cubic
Fixes attach scenario for free products so owned free plans return "active" (or "renew" if canceling) instead of "new". This ensures GET /products_beta marks the current free plan correctly and the pricing table shows the "Current Plan" badge.
Written for commit 9acd894. Summary will update on new commits.
Greptile Summary
Fixes a bug where
GET /products_betareturnedscenario: 'new'instead ofscenario: 'active'for free products the customer already owns. This caused the pricing table to miss the "Current Plan" badge.getAttachScenario, added a check forcurSameProduct(exact product ID match) before defaulting toAttachScenario.New. When a customer owns the exact free product, it now correctly returnsActiveorRenew(if canceling).curMainProductmatches by group (not exact ID), so when multiple free products exist in the same group, it could pick a different product — causing the exact-ID check at line 61 to miss and the free-to-free block to unconditionally returnNew.curSameProductvariable.Confidence Score: 5/5
Important Files Changed
curSameProductcheck in the free-to-free block to return Active/Renew when the customer owns the exact free product, instead of unconditionally returning New. Clean, minimal fix consistent with existing patterns.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[getAttachScenario] --> B{fullCus exists?} B -- No --> C[Return New] B -- Yes --> D[getExistingCusProducts] D --> E{isOneOff?} E -- Yes --> C E -- No --> F{is paid add-on?} F -- Yes --> G{curSameProduct exists?} G -- Yes --> H{canceling?} H -- Yes --> I[Return Renew] H -- No --> J[Return Active] G -- No --> K[Return New] F -- No --> L{is add-on?} L -- Yes --> K L -- No --> M{curMainProduct exists?} M -- No --> K M -- Yes --> N{curMainProduct.id == fullProduct.id?} N -- Yes --> O{canceling?} O -- Yes --> I O -- No --> J N -- No --> P{scheduled product?} P -- Yes --> Q[Return Scheduled] P -- No --> R{both free?} R -- Yes --> S{curSameProduct exists?} S -- Yes --> T{canceling?} T -- Yes --> I T -- No --> J S -- No --> K R -- No --> U{isUpgrade?} U -- Yes --> V[Return Upgrade] U -- No --> W{cur is paid, target is free?} W -- Yes --> X[Return Cancel] W -- No --> Y[Return Downgrade] style S fill:#90EE90,stroke:#006400,color:#000 style T fill:#90EE90,stroke:#006400,color:#000Last reviewed commit: 9acd894
(2/5) Greptile learns from your feedback when you react with thumbs up/down!