{"record":{"id":"a8732939a2b90c09","repo":"nautechsystems/nautilus_trader","slug":"strategy-strategy-id-state-callback-not-found","errorCode":null,"errorMessage":"Strategy {strategy_id} state callback not found","messagePattern":"Strategy (.+?) state callback not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1689,"sourceCode":"                    .copied()\n                    .map(|callbacks| (*actor_id, callbacks))\n                    .ok_or_else(|| anyhow::anyhow!(\"Actor {actor_id} state callback not found\"))\n            })\n            .collect()\n    }\n\n    fn strategy_state_callbacks(\n        &self,\n    ) -> anyhow::Result<Vec<(StrategyId, ComponentStateCallbacks)>> {\n        self.strategy_ids\n            .iter()\n            .map(|strategy_id| {\n                self.strategy_state_callbacks\n                    .get(strategy_id)\n                    .copied()\n                    .map(|callbacks| (*strategy_id, callbacks))\n                    .ok_or_else(|| {\n                        anyhow::anyhow!(\"Strategy {strategy_id} state callback not found\")\n                    })\n            })\n            .collect()\n    }\n\n    fn load_component_state<T>(\n        component_id: Ustr,\n        state: PersistedComponentState,\n    ) -> anyhow::Result<()>\n    where\n        T: DataActor + DataActorNative + Debug + 'static,\n    {\n        let mut component = try_get_actor_unchecked::<T>(&component_id).ok_or_else(|| {\n            anyhow::anyhow!(\"Component {component_id} not found in actor registry\")\n        })?;\n        component.on_load(state)\n    }\n","sourceCodeStart":1671,"sourceCodeEnd":1707,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1671-L1707","documentation":"Raised in `Trader::strategy_state_callbacks` when a strategy ID listed for state recovery has no registered save/load callbacks in the trader's `strategy_state_callbacks` map. The trader cannot persist or restore that strategy's state, so it errors rather than silently skipping it.","triggerScenarios":"Calling trader start/state save while a strategy_id referenced by recovery has no callback entry — typically the strategy was registered without state callbacks, or was removed (e.g. via `retire_strategy`, which clears `strategy_state_callbacks`) while still referenced by the recovery path.","commonSituations":"Removing a strategy concurrently with a state-save pass; custom strategy registration bypassing the standard callback registration; stale recovery metadata referencing a retired strategy.","solutions":["Ensure strategies are added through the standard path so their state callbacks are registered","Avoid removing/retiring a strategy while state save/load is in progress; serialize lifecycle operations","Keep recovery metadata in sync with `strategy_state_callbacks` after `remove_strategy`/`retire_strategy`","Check the reported `strategy_id` against your configured strategies and drop it from recovery if intentionally removed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before state save/load, confirm each strategy has callbacks\nfor id in recovery_strategy_ids {\n    assert!(trader.has_strategy_state_callbacks(&id), \"missing callbacks for {id}\");\n}","typeGuard":"fn has_strategy_callbacks(trader: &Trader, strategy_id: &StrategyId) -> bool {\n    trader.strategy_state_callbacks().contains_key(strategy_id)\n}","tryCatchPattern":null,"preventionTips":["Add strategies via the standard registration path so callbacks exist","Serialize strategy retirement with state save/load passes","Update recovery metadata immediately after `remove_strategy`/`retire_strategy`","Audit for strategies configured for recovery but registered without callbacks"],"tags":["strategy","state","callback","registry"],"backgroundTag":"entity-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}