-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(checkout v3): Auto-open sliders for customers with reserved volumes #101357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| const [showSliders, setShowSliders] = useState<boolean>( | ||
| Object.values(subscription.categories) | ||
| .filter(({category}) => activePlan.checkoutCategories.includes(category)) | ||
| .some( | ||
| ({category, reserved}) => | ||
| getBucket({buckets: activePlan.planCategories[category], events: reserved ?? 0}) | ||
| .price > 0 | ||
| ) | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential bug: The code may pass an `undefined` value to `getBucket` because it doesn't verify that a `category` key exists in `activePlan.planCategories` before access.
-
Description: The code iterates through
subscription.categoriesand, for eachcategory, checks if it's included inactivePlan.checkoutCategories. However, it then directly accessesactivePlan.planCategories[category]and passes the result togetBucket. The type definition foractivePlan.planCategoriesis aPartialrecord, meaning a category can exist incheckoutCategorieswithout a corresponding key inplanCategories. In this scenario,undefinedis passed togetBucket, which will throw an error and crash the component. This failure pattern is confirmed by existing production errors wheregetBucketfails when itsbucketsargument is undefined, such as in this issue. -
Suggested fix: In the
.filter()call, add a check to ensure thatactivePlan.planCategories[category]is truthy before attempting to use it. For example:.filter(({category}) => activePlan.checkoutCategories.includes(category) && activePlan.planCategories[category]).
severity: 0.85, confidence: 0.98
Did we get this right? 👍 / 👎 to inform future reviews.
…mes (#101357) Auto-opens the `Reserve additional volume` substep for customers that already have at least one category reserved above platform volume.
Auto-opens the
Reserve additional volumesubstep for customers that already have at least one category reserved above platform volume.