{"record":{"id":"107c5ff201d97e34","repo":"nautechsystems/nautilus_trader","slug":"cannot-remove-actor-actor-id-not-found","errorCode":null,"errorMessage":"Cannot remove actor, {actor_id} not found","messagePattern":"Cannot remove actor, (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/system/src/trader.rs","lineNumber":1318,"sourceCode":"        if !self.actor_ids.contains(actor_id) {\n            anyhow::bail!(\"Cannot stop actor, {actor_id} not found\");\n        }\n        stop_component(&actor_id.inner())\n    }\n\n    /// Removes the actor with the given `actor_id`.\n    ///\n    /// Will stop the actor first if it is currently running. Disposes the actor\n    /// and removes it from the trader's tracking.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the actor is not registered, or if disposal fails. A failed disposal\n    /// keeps the actor registered and tracked, and leaves it `Faulted`; see [`Component::dispose`].\n    /// Calling this again retires the actor.\n    pub fn remove_actor(&mut self, actor_id: &ActorId) -> anyhow::Result<()> {\n        if !self.actor_ids.contains(actor_id) {\n            anyhow::bail!(\"Cannot remove actor, {actor_id} not found\");\n        }\n\n        // Stop if running, then dispose\n        let _ = stop_component(&actor_id.inner());\n        self.retire_actor(*actor_id)?;\n\n        log::info!(\"Removed actor {actor_id} from trader {}\", self.trader_id);\n        Ok(())\n    }\n\n    /// Starts the strategy with the given `strategy_id`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the strategy is not registered or cannot be started.\n    pub fn start_strategy(&self, strategy_id: &StrategyId) -> anyhow::Result<()> {\n        if !self.strategy_ids.contains(strategy_id) {\n            anyhow::bail!(\"Cannot start strategy, {strategy_id} not found\");","sourceCodeStart":1300,"sourceCodeEnd":1336,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/system/src/trader.rs#L1300-L1336","documentation":"remove_actor was called with an ActorId not present in the trader's registry; the actor was never registered or has already been removed, so there is no component to dispose or deregister and the removal request is rejected.","triggerScenarios":"Thrown at crates/system/src/trader.rs:1318 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register the actor before removing it","Verify the actor ID against the trader's registered actor IDs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}