Skip to content
Open
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: 4 additions & 0 deletions balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ func (l *Blnk) getOrCreateBalanceByIndicator(ctx context.Context, indicator, cur

balance, err := l.datasource.GetBalanceByIndicator(indicator, currency)
if err != nil {
if cfg.Transaction.DisableIndicatorAutoCreate {
span.RecordError(err)
return nil, fmt.Errorf("balance with indicator '%s' not found and auto-creation is disabled", indicator)

This comment was marked as low quality.

}
Comment on lines 147 to +152
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

The strict-mode branch triggers on any error from GetBalanceByIndicator, but that method can return non-"not found" errors (e.g., DB/query failures, data parse errors). In those cases this code will incorrectly report "not found" and also drops the original error from the returned error value. Consider only treating the error as "missing balance" when it is actually a not-found condition, and otherwise return/wrap the original error so operational failures aren’t masked.

Copilot uses AI. Check for mistakes.
Comment on lines +149 to +152
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

This new behavior (rejecting @indicator resolution when DisableIndicatorAutoCreate is enabled) isn’t covered by tests. Please add unit/integration coverage that asserts: (1) with the flag enabled, a transaction referencing a non-existent indicator fails and no balance is created; and (2) with the flag disabled, the previous auto-create behavior still works.

Copilot uses AI. Check for mistakes.
span.AddEvent("Creating new balance")
balance = &model.Balance{
Indicator: indicator,
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ type TransactionConfig struct {
EnableCoalescing bool `json:"enable_coalescing" envconfig:"BLNK_TRANSACTION_ENABLE_COALESCING"`
EnableQueuedChecks bool `json:"enable_queued_checks" envconfig:"BLNK_TRANSACTION_ENABLE_QUEUED_CHECKS"`
DisableBatchReferenceCheck bool `json:"disable_batch_reference_check" envconfig:"BLNK_TRANSACTION_DISABLE_BATCH_REFERENCE_CHECK"`
DisableIndicatorAutoCreate bool `json:"disable_indicator_auto_create" envconfig:"BLNK_TRANSACTION_DISABLE_INDICATOR_AUTO_CREATE"`
}

type ReconciliationConfig struct {
Expand Down
Loading