feat(customcurrencies): add configuration flag#4776
Conversation
📝 WalkthroughWalkthroughCustom-currency mutation endpoints now enforce the credits flag at the HTTP layer. Charge services remove internal custom-currency gates and test toggles, while tests configure support through service constructors and semantic setup. ChangesCustom currency gating
Estimated code review effort: 3 (Moderate) | ~25 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 |
ab0d023 to
e66efd0
Compare
e66efd0 to
1d58ed1
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/currencies/handler.go`:
- Around line 25-38: Update the currencies handler constructor New to accept an
injected *slog.Logger and store or propagate it through the handler as required.
Update all production server/router call sites that invoke New to pass the
existing configured logger, without using slog.Default() or introducing a
fallback.
In `@openmeter/server/router/router.go`:
- Around line 526-531: Update the currencyHandler construction to pass the
dedicated custom-currency enablement setting from config instead of
config.Credits.Enabled. Preserve the existing resolveNamespace, CurrencyService,
and error-handler wiring while ensuring custom-currency mutations require the
credits.customCurrenciesEnabled opt-in.
🪄 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 Plus
Run ID: d0702057-6c05-4f5a-bd7a-20ef124f1bfb
📒 Files selected for processing (20)
.agents/skills/charges/SKILL.mdapi/v3/handlers/currencies/create.goapi/v3/handlers/currencies/create_cost_basis.goapi/v3/handlers/currencies/handler.goapi/v3/handlers/currencies/handler_test.goapi/v3/handlers/currencies/list_test.goapi/v3/server/server.goopenmeter/billing/charges/creditpurchase/service/create.goopenmeter/billing/charges/creditpurchase/service/service.goopenmeter/billing/charges/flatfee/service/create.goopenmeter/billing/charges/flatfee/service/service.goopenmeter/billing/charges/service/base_test.goopenmeter/billing/charges/service/creditpurchase_test.goopenmeter/billing/charges/service/flatfee_costbasis_test.goopenmeter/billing/charges/service/invoicable_test.goopenmeter/billing/charges/service/usagebased_costbasis_test.goopenmeter/billing/charges/service/usagebased_test.goopenmeter/billing/charges/usagebased/service/create.goopenmeter/billing/charges/usagebased/service/service.goopenmeter/server/router/router.go
💤 Files with no reviewable changes (8)
- openmeter/billing/charges/flatfee/service/create.go
- .agents/skills/charges/SKILL.md
- openmeter/billing/charges/service/base_test.go
- openmeter/billing/charges/service/usagebased_test.go
- openmeter/billing/charges/creditpurchase/service/create.go
- openmeter/billing/charges/usagebased/service/create.go
- openmeter/billing/charges/service/invoicable_test.go
- openmeter/billing/charges/flatfee/service/service.go
🚧 Files skipped from review as they are similar to previous changes (5)
- api/v3/handlers/currencies/handler_test.go
- api/v3/handlers/currencies/create_cost_basis.go
- api/v3/server/server.go
- api/v3/handlers/currencies/list_test.go
- api/v3/handlers/currencies/create.go
Summary
credits.enabledfeature flag at the v3 currencies API boundarycredits.customCurrenciesEnabledconfigurationWhen credits are disabled, the custom-currency mutation endpoints return
400 Bad Request.Validation
go test -tags=dynamic ./api/v3/handlers/currencies ./app/config ./app/common ./openmeter/billing/charges/creditpurchase/service ./openmeter/billing/charges/flatfee/service ./openmeter/billing/charges/usagebased/servicePOSTGRES_HOST=127.0.0.1 go test -tags=dynamic ./openmeter/billing/charges/servicego vetfor the changed packagesgolangci-lintfor the changed packagesSummary by CodeRabbit
New Features
Bug Fixes
Tests
Greptile Summary
Updates custom-currency handling:
Confidence Score: 5/5
The PR appears safe to merge within the follow-up review scope.
No blocking failure eligible for this follow-up review remains.
Important Files Changed
Reviews (3): Last reviewed commit: "feat(customcurrencies): gate API with cr..." | Re-trigger Greptile
Context used: