Repository navigation
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
| taxConfig := input.TaxConfig.Clone() | ||
| if err := productcatalog.ResolveTaxConfig(ctx, s.taxCodeService, input.Namespace, &taxConfig); err != nil { | ||
| return charges.CustomerCharge{}, fmt.Errorf("resolving charge tax config: %w", err) |
There was a problem hiding this comment.
Failed requests leave tax codes
ResolveTaxConfig can create a tax code before the charge transaction starts. A Stripe-only request with an unmapped code can therefore leave a new tax code behind if charge creation later fails—for example, when a flat-fee request references an unknown feature. The caller receives an error, but the unused tax code stays saved.
Keep tax-code creation and charge persistence in the same transaction so failed requests roll both back.
Prompt To Fix With AI
This is a comment left during a code review.
Path: openmeter/billing/charges/service/api.go
Line: 43-45
Comment:
**Failed requests leave tax codes**
`ResolveTaxConfig` can create a tax code before the charge transaction starts. A Stripe-only request with an unmapped code can therefore leave a new tax code behind if charge creation later fails—for example, when a flat-fee request references an unknown feature. The caller receives an error, but the unused tax code stays saved.
Keep tax-code creation and charge persistence in the same transaction so failed requests roll both back.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.There was a problem hiding this comment.
We accept leftover tax codes from failed charge creation for now and are leaving this out of scope for this PR. We plan to implement a proper resolver later, which will ensure these tax codes are not left behind when charge creation fails.
6f024e7 to
1849fcf
Compare
Overview
V3 customer charge creation ignored
tax_code.idand discardedstripe.code, allowing successful requests to persist a default tax code instead of the requested one. Preserve the full tax configuration through the API facade, apply the documented reference precedence, and resolve tax-code identity before constructing the persisted charge intent.Notes for reviewer
make lint-go-fastpassed.make test-nocacherun was interrupted after the local database became unavailable; full-suite validation remains for CI.Summary by CodeRabbit


Confidence Score: 5/5
The PR appears safe to merge, with the previously reported non-blocking cleanup issue still present.Fix with agent prompt
Summary
Customer charge creation now keeps and resolves the full tax configuration before building flat-fee and usage-based charge intents.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Customer charge request] --> B[Convert full tax configuration] B --> C[Validate input and check namespace] C --> D[Resolve explicit ID or Stripe code] D --> E[Build charge intent] E --> F[Apply defaults when no code was selected] F --> G[Save charge in transaction]Reviews (2) · Last reviewed commit: "fix(billing): preserve tax codes for v3 ..." · Reviewed by Greptile