{"record":{"id":"4f286d03d9d31df4","repo":"nautechsystems/nautilus_trader","slug":"actor-for-id-not-found","errorCode":null,"errorMessage":"Actor for {id} not found","messagePattern":"Actor for (.+?) not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/common/src/actor/registry.rs","lineNumber":209,"sourceCode":"/// Only the exact ID is removed, so unrelated actors sharing the thread-local registry are\n/// untouched.\npub fn deregister_actor(id: &Ustr) {\n    with_actor_registry(|registry| registry.remove(id));\n}\n\n/// Returns a guard providing mutable access to the registered actor of type `T`.\n///\n/// The returned [`ActorRef`] holds an `Rc` to keep the actor alive, preventing\n/// use-after-free if the actor is removed from the registry.\n///\n/// # Panics\n///\n/// - Panics if no actor with the specified `id` is found in the registry.\n/// - Panics if the stored actor is not of type `T`.\n#[must_use]\npub fn get_actor_unchecked<T: Actor>(id: &Ustr) -> ActorRef<T> {\n    let actor_rc = with_actor_registry(|registry| registry.get(id))\n        .unwrap_or_else(|| panic!(\"Actor for {id} not found\"));\n\n    match actor_ref_from_rc(actor_rc) {\n        Ok(actor_ref) => actor_ref,\n        Err(ActorRefError {\n            expected_type,\n            actual_type,\n        }) => {\n            panic!(\n                \"Actor type mismatch for '{id}': expected {expected_type:?}, found {actual_type:?}\"\n            )\n        }\n    }\n}\n\n/// Attempts to get a guard providing mutable access to the registered actor.\n///\n/// Returns `None` if the actor is not found or the type doesn't match.\n#[must_use]","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/actor/registry.rs#L191-L227","documentation":"This panic comes from ActorRegistry::get_actor_unchecked, a lookup that assumes an actor with the given Ustr id exists. When the registry contains no entry for the id, the function panics with 'Actor for {id} not found'. It is the caller's responsibility to ensure the actor was registered before calling this unchecked accessor.","triggerScenarios":"Calling ActorRegistry::get_actor_unchecked::<T>(id) (via with_actor_registry) with an id that was never registered, or after the actor was registered under a different id, or after the registry was reset/cleared.","commonSituations":"Typos or case mismatches in actor names; looking up an actor before the system has finished spawning/registering it; actors registered in a different registry instance than the one queried; tests that forget to register the actor under test.","solutions":["Verify the actor was registered with the exact same Ustr id (Ustr is case-sensitive) before calling get_actor_unchecked","Ensure the actor's registration/spawn completes before the lookup (ordering of startup code)","Print or log the registry contents to compare against the id being requested","Use a checked lookup (registry.get(id)) returning an Option instead of the unchecked panic path"],"exampleFix":"// before\nlet orders = get_actor_unchecked::<MockActor>(&ustr(\"OrderManger\"));\n// after\nlet id = ustr(\"OrderManager\"); // fix id spelling\nlet orders = get_actor_unchecked::<MockActor>(&id);","handlingStrategy":"validation","validationCode":"if registry.get(&id).is_some() {\n    let actor = get_actor_unchecked::<T>(&id);\n} else {\n    eprintln!(\"actor {id} not registered\");\n}","typeGuard":"fn actor_registered(registry: &ActorRegistry, id: &Ustr) -> bool {\n    registry.get(id).is_some()\n}","tryCatchPattern":null,"preventionTips":["Keep actor ids in constants shared between registration and lookup","Register all actors during an explicit init phase before any lookups","Prefer checked lookups returning Option/Result in non-test code"],"tags":["rust","actor-registry","panic","lookup-failure"],"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"}