Repository navigation
Validate customer billing for invoice-funded credit grants - #4608
Conversation
Greptile SummaryThis PR validates billing setup before creating invoice-funded credit grants. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "Validate customer billing for invoice cr..." | Re-trigger Greptile |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 WalkthroughWalkthroughAdds a ChangesInvoice-funded credit grant billing validation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 `@openmeter/billing/validators/customerbilling/validator.go`:
- Around line 29-33: In validator.go, the customer billing validation path in
the customer profile flow should guard the invoicing app before calling
customerapp.AsCustomerApp, since MergedProfile.Apps.Invoicing may be nil and
AsCustomerApp relies on GetID()/GetType() and can panic. Add a nil check around
appBase in the validator logic, return a clear validation error when invoicing
is missing, and only call customerapp.AsCustomerApp when the app is present.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: aeae4854-e8b2-45f5-a4cd-e6aa73013f3c
📒 Files selected for processing (7)
app/common/creditgrant.goopenmeter/billing/creditgrant/service/service.goopenmeter/billing/validators/customerbilling/validator.goopenmeter/billing/validators/subscription/validator.gotest/app/stripe/invoice_credits_test.gotest/app/stripe/invoice_test.gotest/credits/creditgrant_test.go
a992cdc to
ed8d285
Compare
What
Why
Invoice-funded credit grants could create pending invoice artifacts for customers whose billing profile uses the Stripe app but whose customer app data is missing. The later invoice issuing path then failed with a Stripe customer precondition error, leaving the grant invoice in a pending state.
Validation
go test -tags=dynamic ./openmeter/billing/validators/... ./openmeter/billing/creditgrant/service ./app/commongo vet -tags=dynamic ./openmeter/billing/validators/... ./openmeter/billing/creditgrant/service ./app/common ./test/app/stripe ./test/creditsenv POSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./test/app/stripe -run TestStripeInvoicing/TestInvoiceFundedCreditGrantRequiresStripeCustomerDataenv POSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./test/credits -run TestCreditGrantTestSuite/TestCreateInvoiceFundedCreatesInvoiceArtifactsSummary by CodeRabbit