nautechsystems/nautilus_trader · error

Invalid `exec_algorithm_id`/`actor_id` type

Error message

Invalid `exec_algorithm_id`/`actor_id` type

What it means

When wiring a Python data actor reference, the `exec_algorithm_id`/`actor_id` config value must be extractable as an `ActorId`, a Py `ActorId`, or a string parseable by `ActorId::new_checked`. If none succeeds, the code bails with this message. It is a type/format validation of the identifier supplied in the actor's config.

Source

Thrown at crates/live/src/python/node.rs:1576

                    .map_err(|e| anyhow::anyhow!("Failed to extract PyDataActor: {e}"))?;

                // Extract ID from config: prefer exec_algorithm_id, fall back to actor_id
                if let Some(config_obj) = config_instance.as_ref() {
                    let id_attr = config_obj
                        .getattr("exec_algorithm_id")
                        .ok()
                        .filter(|v| !v.is_none())
                        .or_else(|| config_obj.getattr("actor_id").ok().filter(|v| !v.is_none()));

                    if let Some(id_value) = id_attr {
                        let actor_id_val = if let Ok(eaid) = id_value.extract::<ExecAlgorithmId>() {
                            ActorId::new(eaid.inner())
                        } else if let Ok(aid) = id_value.extract::<ActorId>() {
                            aid
                        } else if let Ok(aid_str) = id_value.extract::<String>() {
                            ActorId::new_checked(&aid_str)?
                        } else {
                            anyhow::bail!("Invalid `exec_algorithm_id`/`actor_id` type");
                        };
                        py_data_actor_ref.set_actor_id(actor_id_val);
                    }

                    if let Some(val) = extract_bool_config_attr(config_obj, "log_events") {
                        py_data_actor_ref.set_log_events(val);
                    }

                    if let Some(val) = extract_bool_config_attr(config_obj, "log_commands") {
                        py_data_actor_ref.set_log_commands(val);
                    }
                }

                py_data_actor_ref.set_python_instance(&python_exec_algorithm)?;

                let actor_id = py_data_actor_ref.actor_id();

                Ok((python_exec_algorithm.unbind(), None, actor_id))

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass the id as a string in the format `ActorId::new_checked` accepts (e.g. a valid 'NAME-001' style identifier or UUID).
  2. Pass a nautilus_trader `ActorId` instance instead of an arbitrary object.
  3. Log/inspect the actual type of the config value being passed.
  4. Construct the id via `ActorId(value)` in Python and pass that object.

Example fix

// before
config = {"actor_id": 12345}
// after
config = {"actor_id": "MyActor-001"}
Defensive patterns

Strategy: validation

Validate before calling

def valid_actor_id(v):
    from nautilus_trader.model.identifiers import ActorId
    if isinstance(v, ActorId):
        return True
    if isinstance(v, str) and v:
        try:
            ActorId(v)
            return True
        except Exception:
            return False
    return False

assert valid_actor_id(config["actor_id"]), "actor_id must be ActorId or valid id string"

Type guard

def is_actor_id(v) -> bool:
    from nautilus_trader.model.identifiers import ActorId
    return isinstance(v, (ActorId, str)) and bool(v)

Try / catch

try:
    node.add_data_actor(...)
except Exception as e:
    if "Invalid `exec_algorithm_id`/`actor_id` type" in str(e):
        print("fix actor_id: pass ActorId(...) or a valid identifier string")
    raise

Prevention

When it happens

Trigger: Passing an `actor_id`/`exec_algorithm_id` in the actor config that is neither an ActorId instance nor a valid Uuid/identifier string — e.g. an int, None, dict, or a malformed string.

Common situations: Typos in config dicts, passing the actor object itself instead of its id, or a string with wrong format (not a valid Nautilus identifier).

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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