fix(billing): translate stripe errors in billing services - #1850
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Coverage Report for CI Build 30974219068Coverage increased (+0.005%) to 47.564%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
8c9ade1 to
fdad684
Compare
fdad684 to
24b5f0b
Compare
rohilsurana
left a comment
There was a problem hiding this comment.
I verified the coverage claim on this branch: 32 stripeClient call sites across the five services, and every one either wraps its error with TranslateStripeError or reaches it through an iterator .Err() check that wraps. No err.(*stripe.Error) type assertions are left under billing/.
The two tolerated cases keep their old behavior: a customer already deleted on Stripe is still tolerated during Delete, and a missing subscription still becomes ErrSubscriptionOnProviderNotFound. The ErrorCodeInvoiceUpcomingNone special case in GetUpcoming is also preserved.
The ListPaymentMethods fix is a real bug fix. A failed list used to look like an empty list.
Two small comments inline.
rohilsurana
left a comment
There was a problem hiding this comment.
LGTM, verified all stripe call sites are covered
24b5f0b to
e9476ad
Compare
Wrap every stripe call in the customer, subscription, checkout, product, and invoice services with the stripe error translator, so a typed provider error reaches the caller instead of a raw stripe error. The old type-assertion checks now use errors.Is and errors.As, which also work on wrapped errors. Product and invoice calls that returned bare errors now carry context. The payment method list iterator error, previously dropped, is now checked. Part of #1836. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
e9476ad to
5ade408
Compare
What
Wraps every stripe call in the billing services with
TranslateStripeErrorfrom #1849, so a typed provider error leaves the service instead of a raw stripe error. Touches the customer, subscription, checkout, product, and invoice services — all 30 stripe call sites.Along the way:
err.(*stripe.Error)type assertions becomeerrors.Is/errors.As, which also match wrapped errors. The type assertion silently failed on any error that had been wrapped.ListPaymentMethodsnever checked the stripe iterator's error, so a failed list looked like an empty list. It now returns the error.Behavior kept as before: a customer already deleted on Stripe is still tolerated during delete, and a missing subscription still maps to
ErrSubscriptionOnProviderNotFound.Part of #1836. Stack: translator (#1849) → this PR → handler error mapping.
🤖 Generated with Claude Code