fix(billing): disallow charge intent field overrides#4617
Conversation
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesImmutable charge intent and override handling
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 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 |
Greptile SummaryThis PR makes charge feature and tax attribution immutable on charge intents. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix(billing): handle optional flat fee f..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
openmeter/billing/charges/usagebased/charge.go (1)
394-415: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTiny duplication heads-up (optional).
GetTaxConfig(Line 396) andGetBaseTaxConfig(Line 413) now return the exact samei.intent.TaxConfig, and similarlyGetFeatureKeymirrorsGetBaseFeatureKey. Since tax/feature are immutable now, the "base" vs effective distinction has collapsed. If the dual naming isn't needed for an external API contract, you could collapse each pair to one method to avoid future confusion. Totally fine to leave as-is if the names carry intent for callers.🤖 Prompt for 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. In `@openmeter/billing/charges/usagebased/charge.go` around lines 394 - 415, `OverridableIntent` now has duplicate accessors for the same immutable values: `GetTaxConfig` and `GetBaseTaxConfig` both return `i.intent.TaxConfig`, and the same pattern exists for the feature-key methods. If the separate “base” naming is not required for the public API, collapse each pair into a single accessor and update callers to use the remaining method; otherwise, keep both but make the naming intent explicit in the `OverridableIntent` methods to avoid confusion.
🤖 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 `@api/v3/handlers/customers/charges/convert.go`:
- Line 70: The flat-fee FeatureKey field is now optional and should remain null
when unset, so update the customer charge conversion in convert.go to preserve
the pointer value from intent.FeatureKey rather than coercing it to an empty
string. Check the response mapping around the FeatureKey assignment in the
charge conversion path and make sure the API output reflects nil/omitted for
unset values while still passing through real feature keys unchanged.
---
Nitpick comments:
In `@openmeter/billing/charges/usagebased/charge.go`:
- Around line 394-415: `OverridableIntent` now has duplicate accessors for the
same immutable values: `GetTaxConfig` and `GetBaseTaxConfig` both return
`i.intent.TaxConfig`, and the same pattern exists for the feature-key methods.
If the separate “base” naming is not required for the public API, collapse each
pair into a single accessor and update callers to use the remaining method;
otherwise, keep both but make the naming intent explicit in the
`OverridableIntent` methods to avoid confusion.
🪄 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: f79dff40-3383-4e1b-8bdf-531d95bf1dc5
⛔ Files ignored due to path filters (17)
openmeter/ent/db/chargecreditpurchase_create.gois excluded by!**/ent/db/**openmeter/ent/db/chargecreditpurchase_update.gois excluded by!**/ent/db/**openmeter/ent/db/chargeflatfee_create.gois excluded by!**/ent/db/**openmeter/ent/db/chargeflatfee_update.gois excluded by!**/ent/db/**openmeter/ent/db/chargeflatfeeoverride.gois excluded by!**/ent/db/**openmeter/ent/db/chargeflatfeeoverride/chargeflatfeeoverride.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebased_create.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebased_update.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebasedoverride.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebasedoverride/chargeusagebasedoverride.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebasedoverride/where.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebasedoverride_create.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebasedoverride_update.gois excluded by!**/ent/db/**openmeter/ent/db/migrate/schema.gois excluded by!**/ent/db/**openmeter/ent/db/mutation.gois excluded by!**/ent/db/**openmeter/ent/db/setorclear.gois excluded by!**/ent/db/**tools/migrate/migrations/atlas.sumis excluded by!**/*.sum,!**/*.sum
📒 Files selected for processing (59)
api/v3/handlers/customers/charges/convert.goopenmeter/billing/charges/charge.goopenmeter/billing/charges/creditpurchase/adapter/charge.goopenmeter/billing/charges/flatfee/adapter/charge.goopenmeter/billing/charges/flatfee/adapter/detailedline_test.goopenmeter/billing/charges/flatfee/adapter/intentoverride.goopenmeter/billing/charges/flatfee/adapter/intentoverride_test.goopenmeter/billing/charges/flatfee/adapter/mapper.goopenmeter/billing/charges/flatfee/adapter/realizationrun_test.goopenmeter/billing/charges/flatfee/charge.goopenmeter/billing/charges/flatfee/service/create.goopenmeter/billing/charges/flatfee/service/creditheninvoice.goopenmeter/billing/charges/flatfee/service/manualedit.goopenmeter/billing/charges/flatfee/service/realizations/service.goopenmeter/billing/charges/meta/intent.goopenmeter/billing/charges/meta/patchlinemanualedit.goopenmeter/billing/charges/meta/patchlinemanualedit_test.goopenmeter/billing/charges/models/chargemeta/mixin.goopenmeter/billing/charges/service/base_test.goopenmeter/billing/charges/service/pendinglines.goopenmeter/billing/charges/service/taxcode_test.goopenmeter/billing/charges/service/truncation_test.goopenmeter/billing/charges/usagebased/adapter/charge.goopenmeter/billing/charges/usagebased/adapter/detailedline_test.goopenmeter/billing/charges/usagebased/adapter/intentoverride.goopenmeter/billing/charges/usagebased/adapter/intentoverride_test.goopenmeter/billing/charges/usagebased/adapter/mapper.goopenmeter/billing/charges/usagebased/charge.goopenmeter/billing/charges/usagebased/service/creditheninvoice_test.goopenmeter/billing/charges/usagebased/service/creditsonly_test.goopenmeter/billing/charges/usagebased/service/lineengine.goopenmeter/billing/charges/usagebased/service/rating/service_test.goopenmeter/billing/charges/usagebased/service/rating/subtract/subtract_test.goopenmeter/billing/charges/usagebased/service/rating/testutils/testutils.goopenmeter/billing/charges/usagebased/service/run/credits.goopenmeter/billing/charges/usagebased/service/run/payment_test.goopenmeter/billing/creditgrant/service/service.goopenmeter/billing/errors.goopenmeter/billing/worker/subscriptionsync/service/reconciler/patchcharge_test.goopenmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeflatfee.goopenmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.goopenmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.goopenmeter/ent/schema/chargescreditpurchase.goopenmeter/ent/schema/chargesflatfee.goopenmeter/ent/schema/chargesusagebased.goopenmeter/ledger/chargeadapter/creditpurchase_test.goopenmeter/ledger/chargeadapter/flatfee.goopenmeter/ledger/chargeadapter/flatfee_test.goopenmeter/ledger/chargeadapter/usagebased.goopenmeter/ledger/chargeadapter/usagebased_test.goopenmeter/ledger/customerbalance/calculation.goopenmeter/ledger/customerbalance/expired_loader_test.goopenmeter/ledger/customerbalance/service.goopenmeter/ledger/customerbalance/testenv_test.gotest/app/stripe/invoice_credits_test.gotest/credits/base.gotest/credits/sanity_test.gotools/migrate/migrations/20260630145544_deprecate_charge_override_tax_feature.down.sqltools/migrate/migrations/20260630145544_deprecate_charge_override_tax_feature.up.sql
|
Greptile follow-up:
|
Summary
Validation
Summary by CodeRabbit