Skip to content

Fix/settlement mode api#4470

Merged
rolosp merged 23 commits into
mainfrom
fix/settlement-mode-api
Jun 9, 2026
Merged

Fix/settlement mode api#4470
rolosp merged 23 commits into
mainfrom
fix/settlement-mode-api

Conversation

@rolosp

@rolosp rolosp commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Optional settlement mode for subscription create/change (credit-only or credit-then-invoice) with request-level override.
    • Feature flag control for credits enabling—platform can block credit-only operations when disabled.
  • Refactor

    • Redesigned feature-gate wiring and middleware across APIs and services for more consistent, reliable feature-flag evaluation.

@rolosp rolosp requested a review from a team as a code owner June 1, 2026 20:20
@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds optional subscription SettlementMode to API/specs and propagates it through handlers and services; introduces a FeatureGateChecker, middleware, config, and wiring; enforces credits gating in workflow/reconciler; updates router/server wiring and tests.

Changes

Settlement Mode Override & Feature Gate System

Layer / File(s) Summary
Feature gate core and middleware
pkg/featuregate/featuregate.go, pkg/featuregate/featuregate_test.go
Add Gate interface, FeatureGateChecker with LRU caching, Flags validation, ContextResolver and generic operation middleware.
Config and Wire providers
app/config/featuregate.go, app/config/config.go, app/config/testdata/complete.yaml, app/common/featuregate.go, app/common/featuregate_test.go, cmd/*/wire.go, cmd/*/wire_gen.go
Introduce FeatureGateConfiguration, NewFeatureGateChecker factory, Wire provider set, and default test config for feature flags; update generated wire code to construct/checker.
API specs and generated types
api/spec/.../subscription.tsp, api/spec/.../productcatalog/subscription.tsp, api/api.gen.go
Add optional settlement_mode/settlementMode to AIP spec and generated types; move legacy field to change model; refresh embedded swagger.
v3 subscription handlers
api/v3/handlers/subscriptions/create.go, api/v3/handlers/subscriptions/change.go
Accept optional SettlementMode in requests and forward it into plansubscription requests (pointer conversion).
Subscription service types and plan propagation
openmeter/productcatalog/subscription/service.go, openmeter/productcatalog/subscription/service/create.go, openmeter/productcatalog/subscription/service/change.go
Add SettlementMode to service request structs and apply request-provided overrides to PlanInput or resolved plan before conversion.
Product catalog HTTP handlers (credits via context)
openmeter/productcatalog/plan/httpdriver/*, openmeter/productcatalog/subscription/http/*
Remove handler-level gate fields, derive settlement-mode pointers, and use featuregate context resolver for credits checks; pass settlement mode into workflow input.
Workflow and enforcement
openmeter/subscription/workflow/service/subscription.go, openmeter/subscription/workflow/service/subscription_test.go
Reject credit-only plan creation/changes when credits are disabled (feature-gate checked) and add tests.
Router / server wiring
openmeter/server/router/*, openmeter/server/server.go, api/v3/server/server.go, api/v3/server/routes.go, cmd/server/main.go
Introduce NamespaceDecoder usage, change Config.FeatureGate type to checker pointer, validate checker, and wrap plan/subscription write routes with featuregate middleware.
Billing sync & reconciler
openmeter/billing/worker/subscriptionsync/service/*
Replace gate+creditsFlag with FeatureGateChecker, validate checker, and use checker.Enabled(...) for credits enablement; update tests.
Billing registry & wiring
app/common/billing.go, cmd/*/wire_gen.go
Change function signatures to accept *featuregate.FeatureGateChecker and pass constructed checker into billing registry/subscription sync.
Tests and E2E
openmeter/productcatalog/subscription/service/*_test.go, e2e/productcatalog_test.go, various service/router tests
Add unit tests covering settlement-mode override behavior and feature-gated credits; update fixtures to use FeatureGateChecker.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

area/product-catalog, area/subscriptions

Suggested reviewers

  • tothandras
  • turip
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and doesn't convey meaningful information about the changeset, using generic phrasing. Consider a more specific title like 'Add settlement mode override support for subscriptions' or 'Implement settlement mode feature-gated API changes' to better describe the main changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/settlement-mode-api

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rolosp rolosp added release-note/ignore Ignore this change when generating release notes release-note/bug-fix Release note: Bug Fixes and removed release-note/ignore Ignore this change when generating release notes labels Jun 1, 2026
@borosr borosr added the kind/bug Something isn't working label Jun 1, 2026
@borosr borosr requested review from tothandras and turip June 1, 2026 20:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
openmeter/productcatalog/subscription/service/create_test.go (1)

56-56: ⚡ Quick win

Use t.Context() in tests instead of context.Background().

At Line 56 and Line 109, prefer ctx := t.Context() so cancellation/lifecycle stays tied to the test harness.

As per coding guidelines: “In tests, prefer t.Context() when a testing.T or testing.TB is available instead of introducing context.Background(), to keep cancellation and test-scoped lifecycle tied to the test harness.”

Also applies to: 109-109

🤖 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/productcatalog/subscription/service/create_test.go` at line 56,
Replace the use of context.Background() in the test file by tying the context to
the test harness: change occurrences of "ctx := context.Background()" to "ctx :=
t.Context()" inside the test functions (where t is *testing.T) so the
test-scoped cancellation/lifecycle is respected; update both places in
create_test.go where the ctx variable is created.
e2e/productcatalog_test.go (1)

1342-1346: ⚡ Quick win

Assert structured 400 payload here too (not only raw body text).

Nice coverage addition. To make failures less brittle, also assert ApplicationproblemJSON400 is non-nil and check .Detail (same pattern used in the nearby settlement-mode tests).

Also applies to: 1364-1368

🤖 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 `@e2e/productcatalog_test.go` around lines 1342 - 1346, The test currently only
asserts raw 400 body text after calling
client.CreateSubscriptionWithResponse(ctx, create); enhance it to also
decode/assert the structured error: check that res.JSON400 (or the generated
field ApplicationproblemJSON400 from CreateSubscriptionWithResponse) is non-nil
and assert its .Detail contains the expected message (mirror the pattern used in
the settlement-mode tests); i.e., after verifying StatusCode()==400, assert
ApplicationproblemJSON400 != nil and assert ApplicationproblemJSON400.Detail
contains "credits are not enabled on this deployment of OpenMeter".
openmeter/productcatalog/subscription/service/change_test.go (1)

415-415: ⚡ Quick win

Prefer t.Context() in these new subtests.

At Line 415 and Line 464, switch from context.Background() to t.Context() to keep request lifetime bound to the test.

As per coding guidelines: “In tests, prefer t.Context() when a testing.T or testing.TB is available instead of introducing context.Background(), to keep cancellation and test-scoped lifecycle tied to the test harness.”

Also applies to: 464-464

🤖 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/productcatalog/subscription/service/change_test.go` at line 415,
Replace uses of context.Background() in the subtests with t.Context() so the
test-scoped context is used; specifically update the ctx variable initialization
inside the subtests (the lines where ctx := context.Background() appears) to use
the provided testing.T's context (t.Context()) so request lifetime is bound to
the test harness and cancellation signals propagate. Ensure this change is
applied at both occurrences noted in the test (the ctx declarations around line
415 and line 464 in change_test.go).
🤖 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/subscriptions/change.go`:
- Around line 54-57: In the ChangeSubscription handler, the error wrap for the
call to h.isCreditsEnabled(ns) incorrectly says "failed to create subscription";
update the fmt.Errorf call to a correct message such as "failed to change
subscription: %w" (or "failed to determine credits enabled for namespace: %w")
where the current fmt.Errorf is invoked returning ChangeSubscriptionRequest{},
referencing the isCreditsEnabled call and the fmt.Errorf location so logs
reflect the actual operation.

In `@openmeter/productcatalog/subscription/http/change.go`:
- Around line 126-129: The error message returned when h.isCreditsEnabled(ns)
fails is inconsistent: it currently says "failed to create subscription" but the
matching branch uses "failed to change subscription"; update the error returned
in the creditEnabled check inside ChangeSubscriptionRequest flow to use the same
message ("failed to change subscription") so both branches are consistent—locate
the call to h.isCreditsEnabled in the change subscription handler (the block
that returns ChangeSubscriptionRequest{}) and replace the fmt.Errorf message
accordingly.

---

Nitpick comments:
In `@e2e/productcatalog_test.go`:
- Around line 1342-1346: The test currently only asserts raw 400 body text after
calling client.CreateSubscriptionWithResponse(ctx, create); enhance it to also
decode/assert the structured error: check that res.JSON400 (or the generated
field ApplicationproblemJSON400 from CreateSubscriptionWithResponse) is non-nil
and assert its .Detail contains the expected message (mirror the pattern used in
the settlement-mode tests); i.e., after verifying StatusCode()==400, assert
ApplicationproblemJSON400 != nil and assert ApplicationproblemJSON400.Detail
contains "credits are not enabled on this deployment of OpenMeter".

In `@openmeter/productcatalog/subscription/service/change_test.go`:
- Line 415: Replace uses of context.Background() in the subtests with
t.Context() so the test-scoped context is used; specifically update the ctx
variable initialization inside the subtests (the lines where ctx :=
context.Background() appears) to use the provided testing.T's context
(t.Context()) so request lifetime is bound to the test harness and cancellation
signals propagate. Ensure this change is applied at both occurrences noted in
the test (the ctx declarations around line 415 and line 464 in change_test.go).

In `@openmeter/productcatalog/subscription/service/create_test.go`:
- Line 56: Replace the use of context.Background() in the test file by tying the
context to the test harness: change occurrences of "ctx := context.Background()"
to "ctx := t.Context()" inside the test functions (where t is *testing.T) so the
test-scoped cancellation/lifecycle is respected; update both places in
create_test.go where the ctx variable is created.
🪄 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: 634b8696-933d-4a24-a9fb-dc556787e23a

📥 Commits

Reviewing files that changed from the base of the PR and between 8bca288 and baa732b.

⛔ Files ignored due to path filters (7)
  • api/client/go/client.gen.go is excluded by !api/client/**
  • api/client/javascript/src/client/schemas.ts is excluded by !api/client/**
  • api/client/javascript/src/zod/index.ts is excluded by !api/client/**
  • api/client/python/openmeter/_generated/models/_models.py is excluded by !**/_generated/**, !api/client/**
  • api/openapi.cloud.yaml is excluded by !**/openapi.cloud.yaml
  • api/openapi.yaml is excluded by !**/openapi.yaml
  • api/v3/openapi.yaml is excluded by !**/openapi.yaml
📒 Files selected for processing (17)
  • api/api.gen.go
  • api/spec/packages/aip/src/subscriptions/subscription.tsp
  • api/spec/packages/legacy/src/productcatalog/subscription.tsp
  • api/v3/api.gen.go
  • api/v3/handlers/subscriptions/change.go
  • api/v3/handlers/subscriptions/create.go
  • api/v3/handlers/subscriptions/featuregate.go
  • api/v3/handlers/subscriptions/handler.go
  • api/v3/server/server.go
  • e2e/productcatalog_test.go
  • openmeter/productcatalog/subscription/http/change.go
  • openmeter/productcatalog/subscription/http/create.go
  • openmeter/productcatalog/subscription/service.go
  • openmeter/productcatalog/subscription/service/change.go
  • openmeter/productcatalog/subscription/service/change_test.go
  • openmeter/productcatalog/subscription/service/create.go
  • openmeter/productcatalog/subscription/service/create_test.go

Comment thread api/v3/handlers/subscriptions/change.go Outdated
Comment thread openmeter/productcatalog/subscription/http/change.go Outdated
@turip

turip commented Jun 2, 2026

Copy link
Copy Markdown
Member

LGFM please fix the etoe failures

@turip

turip commented Jun 2, 2026

Copy link
Copy Markdown
Member

Also did you check if the settmenet mode is exposed on subscription reads for the v3 api?

@GAlexIHU GAlexIHU left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job

Comment thread api/v3/handlers/subscriptions/featuregate.go Outdated
Comment thread openmeter/productcatalog/subscription/http/change.go Outdated
Comment thread e2e/productcatalog_test.go

@GAlexIHU GAlexIHU left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sry, actually if the settlement_mode = credit_only comes from the plan the check is bypassed i think

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
pkg/featuregate/featuregate.go (1)

57-59: ⚡ Quick win

Consider making the flag registry more maintainable.

The Keys() method returns a hardcoded list of valid feature flags. When new flags are added to the system, this method needs manual updates, which could be easy to forget. Consider maintaining a package-level registry that Keys() reads from, or having flag declarations automatically register themselves.

That said, the current whitelist approach does force explicit declaration of new flags, which might be intentional.

🤖 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 `@pkg/featuregate/featuregate.go` around lines 57 - 59, The Keys() method on
type Flags currently returns a hardcoded slice containing only credits; make the
flag registry maintainable by introducing a package-level registry (e.g., a
slice variable like registeredFlags) that all flag declarations append to
(either via init functions or a RegisterFeatureFlag(func) call) and then have
func (f Flags) Keys() return that registry instead of a hardcoded list; update
the credits declaration to register itself with registeredFlags or call the
RegisterFeatureFlag helper so new flags are automatically included without
editing Keys().
pkg/featuregate/featuregate_test.go (1)

192-192: 💤 Low value

Prefer t.Context() over context.Background() in tests.

These test cases use context.Background() but run inside t.Run() subtests where testing.T is available. Consider using t.Context() instead to tie the context lifecycle to the test harness.

As per coding guidelines: In tests, prefer t.Context() when a testing.T or testing.TB is available instead of introducing context.Background().

Also applies to: 212-212, 235-235, 247-247, 253-253, 260-260

🤖 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 `@pkg/featuregate/featuregate_test.go` at line 192, Tests call
op(context.Background(), ...) inside t.Run subtests; replace those with
t.Context() so the test harness manages the context lifecycle. Update the call
sites that invoke op(...) (and any other helper functions in the same tests) to
pass t.Context() instead of context.Background() — e.g., change
op(context.Background(), "req") to op(t.Context(), "req") in the subtests noted
(and the similar occurrences at the other line numbers).
🤖 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/server/router/router.go`:
- Around line 144-146: Update the validation error message to reference the new
field name: change the error returned when checking c.NamespaceDecoder in
router.go (the block that currently returns errors.New("namespace manager is
required")) to a message like "namespace decoder is required" so it matches the
NamespaceDecoder field; locate the conditional that checks NamespaceDecoder and
replace the string literal accordingly.

---

Nitpick comments:
In `@pkg/featuregate/featuregate_test.go`:
- Line 192: Tests call op(context.Background(), ...) inside t.Run subtests;
replace those with t.Context() so the test harness manages the context
lifecycle. Update the call sites that invoke op(...) (and any other helper
functions in the same tests) to pass t.Context() instead of context.Background()
— e.g., change op(context.Background(), "req") to op(t.Context(), "req") in the
subtests noted (and the similar occurrences at the other line numbers).

In `@pkg/featuregate/featuregate.go`:
- Around line 57-59: The Keys() method on type Flags currently returns a
hardcoded slice containing only credits; make the flag registry maintainable by
introducing a package-level registry (e.g., a slice variable like
registeredFlags) that all flag declarations append to (either via init functions
or a RegisterFeatureFlag(func) call) and then have func (f Flags) Keys() return
that registry instead of a hardcoded list; update the credits declaration to
register itself with registeredFlags or call the RegisterFeatureFlag helper so
new flags are automatically included without editing Keys().
🪄 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: fb400b1f-04b0-48ee-b903-808f851feffc

📥 Commits

Reviewing files that changed from the base of the PR and between 568327c and e1627b4.

📒 Files selected for processing (43)
  • api/v3/handlers/subscriptions/change.go
  • api/v3/handlers/subscriptions/create.go
  • api/v3/server/routes.go
  • api/v3/server/server.go
  • app/common/billing.go
  • app/common/featuregate.go
  • app/common/featuregate_test.go
  • app/config/config.go
  • app/config/config_test.go
  • app/config/credits.go
  • app/config/featuregate.go
  • app/config/testdata/complete.yaml
  • cmd/billing-worker/wire.go
  • cmd/billing-worker/wire_gen.go
  • cmd/jobs/internal/wire.go
  • cmd/jobs/internal/wire_gen.go
  • cmd/server/main.go
  • cmd/server/wire.go
  • cmd/server/wire_gen.go
  • openmeter/billing/worker/subscriptionsync/service/base_test.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patch.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/patch_test.go
  • openmeter/billing/worker/subscriptionsync/service/reconciler/reconciler.go
  • openmeter/billing/worker/subscriptionsync/service/service.go
  • openmeter/billing/worker/subscriptionsync/service/sync_credittheninvoice_test.go
  • openmeter/productcatalog/plan/httpdriver/driver.go
  • openmeter/productcatalog/plan/httpdriver/featuregate.go
  • openmeter/productcatalog/plan/httpdriver/plan.go
  • openmeter/productcatalog/subscription/http/change.go
  • openmeter/productcatalog/subscription/http/create.go
  • openmeter/productcatalog/subscription/http/featuregate.go
  • openmeter/productcatalog/subscription/http/handler.go
  • openmeter/server/router/plan.go
  • openmeter/server/router/router.go
  • openmeter/server/router/subscription.go
  • openmeter/server/server.go
  • openmeter/server/server_test.go
  • openmeter/subscription/workflow/service/subscription.go
  • openmeter/subscription/workflow/service/subscription_test.go
  • pkg/featuregate/featuregate.go
  • pkg/featuregate/featuregate_test.go
  • test/billing/subscription_test.go
  • test/subscription/framework_test.go
💤 Files with no reviewable changes (8)
  • openmeter/productcatalog/subscription/http/featuregate.go
  • openmeter/productcatalog/plan/httpdriver/featuregate.go
  • openmeter/productcatalog/subscription/http/handler.go
  • openmeter/productcatalog/plan/httpdriver/driver.go
  • api/v3/handlers/subscriptions/create.go
  • api/v3/handlers/subscriptions/change.go
  • openmeter/productcatalog/subscription/http/change.go
  • openmeter/productcatalog/subscription/http/create.go
✅ Files skipped from review due to trivial changes (4)
  • app/config/credits.go
  • app/common/featuregate_test.go
  • cmd/jobs/internal/wire_gen.go
  • cmd/server/wire_gen.go

Comment thread openmeter/server/router/router.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
app/config/config.go (2)

149-151: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Duplicate validation is happening for Credits.

Hey, looks like c.Credits.Validate() is being called twice—once at lines 149-151 (with prefix "credits") and again at lines 173-175 (with prefix "credit"). This will produce duplicate error messages with inconsistent prefixes, which could confuse users. You'll want to remove one of these calls.

🔧 Suggested fix

Remove the second validation call:

-	if err := c.Credits.Validate(); err != nil {
-		errs = append(errs, errorsx.WithPrefix(err, "credit"))
-	}
-

Also applies to: 173-175

🤖 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 `@app/config/config.go` around lines 149 - 151, The c.Credits.Validate() call
is being run twice producing duplicate errors with inconsistent prefixes; remove
the redundant call so validation runs only once. Locate the two calls to
c.Credits.Validate() and keep the one that uses the correct prefix
(errorsx.WithPrefix(..., "credits")), then delete the other call (the one using
"credit") to avoid duplicate messages; ensure only the remaining call appends
its result to errs.

228-228: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Duplicate configuration setup for Credits.

ConfigureCredits(v, "credits") is being called twice (lines 228 and 237). This is redundant and should be removed.

🔧 Suggested fix

Remove the duplicate call:

 	ConfigureCustomer(v, "customer")
-	ConfigureCredits(v, "credits")
 	ConfigureTaxCode(v)

Also applies to: 237-237

🤖 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 `@app/config/config.go` at line 228, Remove the duplicate ConfigureCredits
call: locate the repeated ConfigureCredits(v, "credits") invocation in the
config initialization (the symbol ConfigureCredits) and delete the redundant
occurrence so the credits configuration is only set once; ensure no other setup
logic (e.g., surrounding ConfigureX calls) is accidentally removed when cleaning
up the duplicate.
🤖 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.

Outside diff comments:
In `@app/config/config.go`:
- Around line 149-151: The c.Credits.Validate() call is being run twice
producing duplicate errors with inconsistent prefixes; remove the redundant call
so validation runs only once. Locate the two calls to c.Credits.Validate() and
keep the one that uses the correct prefix (errorsx.WithPrefix(..., "credits")),
then delete the other call (the one using "credit") to avoid duplicate messages;
ensure only the remaining call appends its result to errs.
- Line 228: Remove the duplicate ConfigureCredits call: locate the repeated
ConfigureCredits(v, "credits") invocation in the config initialization (the
symbol ConfigureCredits) and delete the redundant occurrence so the credits
configuration is only set once; ensure no other setup logic (e.g., surrounding
ConfigureX calls) is accidentally removed when cleaning up the duplicate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b9519325-6113-439e-884f-10a4fa876906

📥 Commits

Reviewing files that changed from the base of the PR and between e1627b4 and 76b1dd7.

📒 Files selected for processing (3)
  • app/config/config.go
  • app/config/config_test.go
  • app/config/credits.go
💤 Files with no reviewable changes (2)
  • app/config/config_test.go
  • app/config/credits.go

@rolosp rolosp force-pushed the fix/settlement-mode-api branch from e75769b to 6fbaf20 Compare June 9, 2026 11:52
@rolosp rolosp enabled auto-merge (squash) June 9, 2026 11:52
@rolosp rolosp merged commit c394e83 into main Jun 9, 2026
27 of 29 checks passed
@rolosp rolosp deleted the fix/settlement-mode-api branch June 9, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants