nautechsystems/nautilus_trader · error

Actor for not found

Error message

Actor for {id} not found

What it means

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.

Solutions

  1. Verify the actor was registered with the exact same Ustr id (Ustr is case-sensitive) before calling get_actor_unchecked
  2. Ensure the actor's registration/spawn completes before the lookup (ordering of startup code)
  3. Print or log the registry contents to compare against the id being requested
  4. Use a checked lookup (registry.get(id)) returning an Option instead of the unchecked panic path

Example fix

// before
let orders = get_actor_unchecked::<MockActor>(&ustr("OrderManger"));
// after
let id = ustr("OrderManager"); // fix id spelling
let orders = get_actor_unchecked::<MockActor>(&id);
Defensive patterns

Strategy: validation

Validate before calling

if registry.get(&id).is_some() {
    let actor = get_actor_unchecked::<T>(&id);
} else {
    eprintln!("actor {id} not registered");
}

Type guard

fn actor_registered(registry: &ActorRegistry, id: &Ustr) -> bool {
    registry.get(id).is_some()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/4f286d03d9d31df4. Report an issue: GitHub.

Appendix: source

Thrown at crates/common/src/actor/registry.rs:209

/// Only the exact ID is removed, so unrelated actors sharing the thread-local registry are
/// untouched.
pub fn deregister_actor(id: &Ustr) {
    with_actor_registry(|registry| registry.remove(id));
}

/// Returns a guard providing mutable access to the registered actor of type `T`.
///
/// The returned [`ActorRef`] holds an `Rc` to keep the actor alive, preventing
/// use-after-free if the actor is removed from the registry.
///
/// # Panics
///
/// - Panics if no actor with the specified `id` is found in the registry.
/// - Panics if the stored actor is not of type `T`.
#[must_use]
pub fn get_actor_unchecked<T: Actor>(id: &Ustr) -> ActorRef<T> {
    let actor_rc = with_actor_registry(|registry| registry.get(id))
        .unwrap_or_else(|| panic!("Actor for {id} not found"));

    match actor_ref_from_rc(actor_rc) {
        Ok(actor_ref) => actor_ref,
        Err(ActorRefError {
            expected_type,
            actual_type,
        }) => {
            panic!(
                "Actor type mismatch for '{id}': expected {expected_type:?}, found {actual_type:?}"
            )
        }
    }
}

/// Attempts to get a guard providing mutable access to the registered actor.
///
/// Returns `None` if the actor is not found or the type doesn't match.
#[must_use]

View on GitHub (pinned to 18893faf8b)