Skip to content

fix(billing): translate stripe errors in billing services - #1850

Merged
whoAbhishekSah merged 1 commit into
fix/stripe-error-translatorfrom
fix/billing-services-stripe-errors
Aug 5, 2026
Merged

fix(billing): translate stripe errors in billing services#1850
whoAbhishekSah merged 1 commit into
fix/stripe-error-translatorfrom
fix/billing-services-stripe-errors

Conversation

@whoAbhishekSah

Copy link
Copy Markdown
Member

What

Wraps every stripe call in the billing services with TranslateStripeError from #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:

  • The old err.(*stripe.Error) type assertions become errors.Is / errors.As, which also match wrapped errors. The type assertion silently failed on any error that had been wrapped.
  • The product and invoice calls that returned bare errors now carry context ("failed to create price at billing provider: ...").
  • ListPaymentMethods never 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

@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview Aug 5, 2026 11:42am

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ed547f18-8f8b-4fe8-9e60-628f8848451b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 30974219068

Coverage increased (+0.005%) to 47.564%

Details

  • Coverage increased (+0.005%) from the base build.
  • Patch coverage: 44 uncovered changes across 5 files (3 of 47 lines covered, 6.38%).
  • 2 coverage regressions across 1 file.

Uncovered Changes

File Changed Covered %
billing/customer/service.go 15 3 20.0%
billing/invoice/service.go 10 0 0.0%
billing/subscription/service.go 10 0 0.0%
billing/checkout/service.go 7 0 0.0%
billing/product/service.go 5 0 0.0%

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
billing/customer/service.go 2 31.87%

Coverage Stats

Coverage Status
Relevant Lines: 39381
Covered Lines: 18731
Line Coverage: 47.56%
Coverage Strength: 15.4 hits per line

💛 - Coveralls

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread billing/customer/service.go Outdated
Comment thread billing/customer/service.go

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, verified all stripe call sites are covered

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>
@whoAbhishekSah
whoAbhishekSah force-pushed the fix/billing-services-stripe-errors branch from e9476ad to 5ade408 Compare August 5, 2026 11:40
@whoAbhishekSah
whoAbhishekSah merged commit df5181b into main Aug 5, 2026
13 checks passed
@whoAbhishekSah
whoAbhishekSah deleted the fix/billing-services-stripe-errors branch August 5, 2026 11:50
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.

3 participants