Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/config/credits.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type CreditsConfiguration struct {
Enabled bool `yaml:"enabled"`
EnableCreditThenInvoice bool `yaml:"enable_credit_then_invoice"`
EnableCreditThenInvoice bool `yaml:"enableCreditThenInvoice"`

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Please keep backward compatibility for the legacy key during migration.

At Line 11 and Line 24, switching only to enableCreditThenInvoice can break existing configs still using enable_credit_then_invoice and silently change behavior (defaulting to false). Could we support both keys for at least one transition window (or add explicit migration handling)?

Also applies to: 24-24

🤖 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/credits.go` at line 11, The new YAML key change breaks backward
compatibility; update the config parsing so both the new field
EnableCreditThenInvoice (yaml:"enableCreditThenInvoice") and the legacy key
enable_credit_then_invoice are supported during migration: either add a second
struct field (e.g., LegacyEnableCreditThenInvoice bool
`yaml:"enable_credit_then_invoice"`) and coalesce its value into
EnableCreditThenInvoice after unmarshalling, or implement a custom UnmarshalYAML
for the config struct that reads both keys and sets EnableCreditThenInvoice when
the legacy key is present; ensure precedence rules (explicit new key wins) and
that default behavior remains unchanged when neither key is present.

}

func (c CreditsConfiguration) Validate() error {
Expand All @@ -21,5 +21,5 @@ func (c CreditsConfiguration) Validate() error {

func ConfigureCredits(v *viper.Viper) {
v.SetDefault("credits.enabled", false)
v.SetDefault("credits.enable_credit_then_invoice", false)
v.SetDefault("credits.enableCreditThenInvoice", false)
}
2 changes: 1 addition & 1 deletion config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ billing:

credits:
enabled: true
enable_credit_then_invoice: false
enableCreditThenInvoice: false

apps:
baseURL: https://example.com
Expand Down
2 changes: 1 addition & 1 deletion e2e/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ postgres:
# to verify that credit_only settlement mode is rejected when credits are disabled.
credits:
enabled: false
enable_credit_then_invoice: false
enableCreditThenInvoice: false

notification:
lock:
Expand Down
Loading