fix(api): avoid duplicate customer creation on lookup errors#29769
fix(api): avoid duplicate customer creation on lookup errors#29769Adarsh9977 wants to merge 2 commits into
Conversation
|
Welcome to Cal.diy, @Adarsh9977! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/api/v2/src/modules/stripe/stripe.service.ts`:
- Around line 245-250: Serialize the customers.list and stripe.customers.create
flow in the surrounding customer lookup method per user, or supply a stable
per-user idempotency key to creation, so concurrent requests cannot create
duplicate Stripe customers before stripeCustomerId is persisted. Preserve the
existing reuse of customersResponse.data[0].id and assignment of customerId for
both existing and newly created customers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: a08def53-c924-465a-8321-c0dd70d21cfb
📒 Files selected for processing (1)
apps/api/v2/src/modules/stripe/stripe.service.ts
What does this PR do?
createStripeCustomerIdin API v2 so Stripe customer lookup failures no longer silently create duplicate customers.InternalServerErrorExceptioninstead of masking them with a fallback create.Visual Demo (For contributors especially)
A visual demonstration is strongly recommended for both the original and new change (video/image - any one).
Video Demo (if applicable):
Image Demo (if applicable):
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?