{"record":{"id":"aee125bbb318a086","repo":"nautechsystems/nautilus_trader","slug":"component-component-id-not-found-in-actor-regist","errorCode":null,"errorMessage":"Component {component_id} not found in actor registry","messagePattern":"Component (.+?) not found in actor registry","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1703,"sourceCode":"                    .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\n    fn save_component_state<T>(component_id: Ustr) -> anyhow::Result<PersistedComponentState>\n    where\n        T: DataActor + DataActorNative + Debug + 'static,\n    {\n        let 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_save()\n    }\n\n    /// Initializes the trader, transitioning from `PreInitialized` to `Ready` state.\n    ///\n    /// This method must be called before starting the trader.\n    ///","sourceCodeStart":1685,"sourceCodeEnd":1721,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1685-L1721","documentation":"Raised in `Trader::load_component_state` when the global actor registry has no component registered under `component_id` (cast to the requested type `T` via `try_get_actor_unchecked::<T>`). The trader cannot deliver persisted state to a component that is not registered, so state loading fails for it.","triggerScenarios":"Calling state restore with a `PersistedComponentState` whose `component_id` does not resolve to a registered actor of type `T` — the component was never added, was already disposed, or the requested type does not match the registered concrete type.","commonSituations":"Restoring a saved-state snapshot into a system configured with fewer/different components; renamed actor IDs between runs; custom persistence code calling the typed loader with the wrong `T`; restart after the component failed to initialize.","solutions":["Verify the component with that ID is added to the trader/system before state loading runs","Ensure the type parameter `T` matches the concrete registered type of the component","Check for ID renames or config changes between the state-saving run and the restoring run; map or migrate old IDs","Fix any initialization failure that prevented the component from registering, then retry restoration"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// before restoring, confirm the component is registered\nif !trader.is_registered(&component_id) {\n    skip_or_register(component_id);\n}","typeGuard":"fn is_component_registered<T: DataActor>(trader: &Trader, id: &ComponentId) -> bool {\n    trader.try_get_actor::<T>(id).is_some()\n}","tryCatchPattern":"match trader.load_state() {\n    Err(e) if e.to_string().contains(\"not found in actor registry\") => {\n        // reconcile saved component IDs with the current system config\n    }\n    other => other?,\n}","preventionTips":["Keep the system config stable between the state-saving and restoring runs","Register all persisted components before invoking state loading","Map old component IDs to new ones after renames","Pass the correct concrete type when using the typed loader"],"tags":["component","actor-registry","state","not-found"],"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"}