Missing securities error #1784

Closed
Shpigford wants to merge 1 commits from missing-securities-error into main
Shpigford commented 2025-02-04 01:21:06 +08:00 (Migrated from github.com)

To address undefined method 'dig' for nil error on account sync.

{
  "/app/models/account/holding_calculator.rb:51:in 'block in Account::HoldingCalculator#generate_holding_records'",
  "/app/models/account/holding_calculator.rb:49:in 'Hash#each'",
  "/app/models/account/holding_calculator.rb:49:in 'Enumerable#map'",
  "/app/models/account/holding_calculator.rb:49:in 'Account::HoldingCalculator#generate_holding_records'",
  "/app/models/account/holding_calculator.rb:25:in 'block in Account::HoldingCalculator#reverse_holdings'",
  "/app/models/account/holding_calculator.rb:22:in 'Date#downto'",
  "/app/models/account/holding_calculator.rb:22:in 'Enumerator#each'",
  "/app/models/account/holding_calculator.rb:22:in 'Enumerable#map'",
  "/app/models/account/holding_calculator.rb:22:in 'Account::HoldingCalculator#reverse_holdings'",
  "/app/models/account/holding_calculator.rb:9:in 'Account::HoldingCalculator#calculate'"
}
To address `undefined method 'dig' for nil` error on account sync. ``` { "/app/models/account/holding_calculator.rb:51:in 'block in Account::HoldingCalculator#generate_holding_records'", "/app/models/account/holding_calculator.rb:49:in 'Hash#each'", "/app/models/account/holding_calculator.rb:49:in 'Enumerable#map'", "/app/models/account/holding_calculator.rb:49:in 'Account::HoldingCalculator#generate_holding_records'", "/app/models/account/holding_calculator.rb:25:in 'block in Account::HoldingCalculator#reverse_holdings'", "/app/models/account/holding_calculator.rb:22:in 'Date#downto'", "/app/models/account/holding_calculator.rb:22:in 'Enumerator#each'", "/app/models/account/holding_calculator.rb:22:in 'Enumerable#map'", "/app/models/account/holding_calculator.rb:22:in 'Account::HoldingCalculator#reverse_holdings'", "/app/models/account/holding_calculator.rb:9:in 'Account::HoldingCalculator#calculate'" } ```
zachgoll (Migrated from github.com) approved these changes 2025-02-04 02:12:52 +08:00
zachgoll (Migrated from github.com) left a comment

This fix should work. Longer term, I think to address the root cause here, we'll have to move preload_securities directly into the forward_holdings and reverse_holdings methods so that they are preloaded based on the starting portfolio used directly in each of these methods.

This fix should work. Longer term, I think to address the root cause here, we'll have to move `preload_securities` directly into the `forward_holdings` and `reverse_holdings` methods so that they are preloaded based on the starting portfolio used directly in each of these methods.
Shpigford commented 2025-02-04 10:01:40 +08:00 (Migrated from github.com)

Closing in favor of main brain fixes (with logging)

Closing in favor of main brain fixes (with logging)

Pull request closed

Sign in to join this conversation.