Persist unit config - OM-395#4579
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 ignored due to path filters (25)
📒 Files selected for processing (19)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (17)
📝 WalkthroughWalkthroughAdds ChangesUnitConfig persistence
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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 adds
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (8): Last reviewed commit: "feat: persist unit config" | Re-trigger Greptile |
8fd62c5 to
26e55a9
Compare
26e55a9 to
25c3d14
Compare
25c3d14 to
afbbecd
Compare
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/ent/schema/productcatalog.go`:
- Line 206: The package-level scanner identifier UnitConfigValueScanner is
declared twice in openmeter/ent/schema, once in productcatalog.go and once in
ratecard.go, causing a redeclaration error. Remove the duplicate declaration
from one schema and have both ProductCatalog and RateCard reuse the single
shared UnitConfigValueScanner symbol defined in the package so the ent schema
package compiles cleanly.
🪄 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: 5a124512-a7f0-4f25-91f9-4b9242cfc8c3
⛔ Files ignored due to path filters (25)
openmeter/ent/db/addonratecard.gois excluded by!**/ent/db/**openmeter/ent/db/addonratecard/addonratecard.gois excluded by!**/ent/db/**openmeter/ent/db/addonratecard/where.gois excluded by!**/ent/db/**openmeter/ent/db/addonratecard_create.gois excluded by!**/ent/db/**openmeter/ent/db/addonratecard_update.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebased.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebased/chargeusagebased.gois excluded by!**/ent/db/**openmeter/ent/db/chargeusagebased/where.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/planratecard.gois excluded by!**/ent/db/**openmeter/ent/db/planratecard/planratecard.gois excluded by!**/ent/db/**openmeter/ent/db/planratecard/where.gois excluded by!**/ent/db/**openmeter/ent/db/planratecard_create.gois excluded by!**/ent/db/**openmeter/ent/db/planratecard_update.gois excluded by!**/ent/db/**openmeter/ent/db/runtime.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 (19)
openmeter/billing/charges/usagebased/adapter/charge.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/worker/subscriptionsync/service/reconciler/patchchargeusagebased.goopenmeter/ent/schema/chargesusagebased.goopenmeter/ent/schema/productcatalog.goopenmeter/ent/schema/ratecard.goopenmeter/productcatalog/addon/adapter/adapter_test.goopenmeter/productcatalog/addon/adapter/addon.goopenmeter/productcatalog/addon/adapter/mapping.goopenmeter/productcatalog/addon/assert.goopenmeter/productcatalog/plan/adapter/adapter_test.goopenmeter/productcatalog/plan/adapter/mapping.goopenmeter/productcatalog/plan/adapter/phase.goopenmeter/productcatalog/plan/assert.gotools/migrate/migrations/20260625202530_add_unit_config.down.sqltools/migrate/migrations/20260625202530_add_unit_config.up.sql
4b422b1 to
b9eee04
Compare
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/ent/db/chargeusagebasedoverride_update.go`:
- Around line 346-350: Guard the unit_config validation in
ChargeUsageBasedOverride.update by explicitly checking for a nil inner value
before calling v.Validate(), since SetOrClearUnitConfig can pass a non-nil
pointer wrapper with a nil UnitConfig and currently panic. Update the validation
path in ChargeUsageBasedOverride_update and any matching duplicate block to
return a ValidationError for "unit_config" when v is nil, then only call
Validate() on a non-nil value.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e9ae772f-20a0-417f-a1ef-3f643887fe25
⛔ Files ignored due to path filters (1)
tools/migrate/migrations/atlas.sumis excluded by!**/*.sum
📒 Files selected for processing (43)
openmeter/billing/charges/usagebased/adapter/charge.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/worker/subscriptionsync/service/reconciler/patchchargeusagebased.goopenmeter/ent/db/addonratecard.goopenmeter/ent/db/addonratecard/addonratecard.goopenmeter/ent/db/addonratecard/where.goopenmeter/ent/db/addonratecard_create.goopenmeter/ent/db/addonratecard_update.goopenmeter/ent/db/chargeusagebased.goopenmeter/ent/db/chargeusagebased/chargeusagebased.goopenmeter/ent/db/chargeusagebased/where.goopenmeter/ent/db/chargeusagebased_create.goopenmeter/ent/db/chargeusagebased_update.goopenmeter/ent/db/chargeusagebasedoverride.goopenmeter/ent/db/chargeusagebasedoverride/chargeusagebasedoverride.goopenmeter/ent/db/chargeusagebasedoverride/where.goopenmeter/ent/db/chargeusagebasedoverride_create.goopenmeter/ent/db/chargeusagebasedoverride_update.goopenmeter/ent/db/migrate/schema.goopenmeter/ent/db/mutation.goopenmeter/ent/db/planratecard.goopenmeter/ent/db/planratecard/planratecard.goopenmeter/ent/db/planratecard/where.goopenmeter/ent/db/planratecard_create.goopenmeter/ent/db/planratecard_update.goopenmeter/ent/db/runtime.goopenmeter/ent/db/setorclear.goopenmeter/ent/schema/chargesusagebased.goopenmeter/ent/schema/productcatalog.goopenmeter/ent/schema/ratecard.goopenmeter/productcatalog/addon/adapter/adapter_test.goopenmeter/productcatalog/addon/adapter/addon.goopenmeter/productcatalog/addon/adapter/mapping.goopenmeter/productcatalog/addon/assert.goopenmeter/productcatalog/plan/adapter/adapter_test.goopenmeter/productcatalog/plan/adapter/mapping.goopenmeter/productcatalog/plan/adapter/phase.goopenmeter/productcatalog/plan/assert.gotools/migrate/migrations/20260625202530_add_unit_config.down.sqltools/migrate/migrations/20260625202530_add_unit_config.up.sql
✅ Files skipped from review due to trivial changes (25)
- openmeter/ent/db/planratecard/where.go
- openmeter/ent/db/chargeusagebasedoverride/where.go
- openmeter/ent/db/addonratecard/where.go
- openmeter/productcatalog/addon/adapter/addon.go
- openmeter/ent/schema/ratecard.go
- openmeter/ent/db/chargeusagebased.go
- openmeter/billing/worker/subscriptionsync/service/reconciler/patchchargeusagebased.go
- tools/migrate/migrations/20260625202530_add_unit_config.up.sql
- openmeter/ent/db/chargeusagebased/chargeusagebased.go
- openmeter/ent/db/addonratecard/addonratecard.go
- openmeter/ent/db/runtime.go
- openmeter/productcatalog/plan/adapter/adapter_test.go
- openmeter/ent/db/setorclear.go
- openmeter/ent/db/planratecard/planratecard.go
- openmeter/ent/db/chargeusagebasedoverride.go
- openmeter/ent/db/planratecard_update.go
- openmeter/ent/db/chargeusagebasedoverride/chargeusagebasedoverride.go
- openmeter/ent/db/addonratecard_update.go
- openmeter/productcatalog/addon/adapter/mapping.go
- openmeter/ent/db/chargeusagebased_update.go
- openmeter/ent/db/addonratecard.go
- openmeter/ent/db/chargeusagebased/where.go
- openmeter/ent/db/chargeusagebasedoverride_create.go
- openmeter/ent/db/chargeusagebased_create.go
- openmeter/ent/db/migrate/schema.go
🚧 Files skipped from review as they are similar to previous changes (13)
- tools/migrate/migrations/20260625202530_add_unit_config.down.sql
- openmeter/productcatalog/plan/assert.go
- openmeter/productcatalog/addon/adapter/adapter_test.go
- openmeter/productcatalog/plan/adapter/mapping.go
- openmeter/ent/schema/productcatalog.go
- openmeter/billing/charges/usagebased/adapter/intentoverride.go
- openmeter/productcatalog/plan/adapter/phase.go
- openmeter/productcatalog/addon/assert.go
- openmeter/ent/schema/chargesusagebased.go
- openmeter/billing/charges/usagebased/adapter/charge.go
- openmeter/billing/charges/usagebased/adapter/intentoverride_test.go
- openmeter/billing/charges/usagebased/charge.go
- openmeter/billing/charges/usagebased/adapter/mapper.go
b9eee04 to
6b30066
Compare
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
6b30066 to
e85ba4b
Compare
Overview
Adds a unit_config jsonb column to the shared rate-card Ent mixin (plan + addon
rate cards), ChargeUsageBased, and ChargeUsageBasedOverride, with a value scanner
and migration, and wires the field through every owned write/read path.
Where it's wired
Set* chain (the two paths that silently diverge).
IntentMutableFields alongside price/discounts, so it's mutable and set on create
override).
Safety / rollout
Additive and gated: authoring is rejected unless unitConfig.enabled is set, so
with the flag off the column is always NULL and behavior is unchanged. Nothing
reads unit_config in rating yet (separate ticket), so this is a no-op in
production.
Out of scope (own tickets)
Invoice-line snapshot, subscription-sync population of the charge intent and the rating mutator.
Summary by CodeRabbit
unit_config) across rate cards, usage-based charges, and charge overrides.unit_config, with proper deep-copy behavior.unit_configmapping on charge and override reads, and ensured create/update flows correctly persist or clearunit_config.unit_configacross base and override intent layers.