nautechsystems/nautilus_trader · error

config_path must be in format 'module.path:ClassName', was {

Error message

config_path must be in format 'module.path:ClassName', was {config_path}

What it means

Thrown by `create_config_instance` when the `config_path` string cannot be split into `module.path:ClassName` because it lacks a `:`. Unlike error 1605, this message names the offending value (`config_path`) directly. Note: if config_path is empty AND config is empty, None config is used instead — this error only fires for non-empty malformed values.

Source

Thrown at crates/system/src/python/registration.rs:563

        .map_err(|e| anyhow::anyhow!("Failed to import module {module_name}: {e}"))?;

    module
        .getattr(class_name)
        .map_err(|e| anyhow::anyhow!("Failed to get class {class_name}: {e}"))
}

fn create_config_instance<'py>(
    py: Python<'py>,
    config_path: &str,
    config: &HashMap<String, serde_json::Value>,
) -> anyhow::Result<Option<Bound<'py, PyAny>>> {
    if config_path.is_empty() && config.is_empty() {
        log::debug!("No config_path or empty config, using None");
        return Ok(None);
    }

    let Some((config_module_name, config_class_name)) = config_path.split_once(':') else {
        anyhow::bail!("config_path must be in format 'module.path:ClassName', was {config_path}");
    };

    if config_module_name.is_empty()
        || config_class_name.is_empty()
        || config_class_name.contains(':')
    {
        anyhow::bail!("config_path must be in format 'module.path:ClassName', was {config_path}");
    }

    log::debug!(
        "Importing config class from module: {config_module_name} class: {config_class_name}"
    );

    let config_module = py
        .import(config_module_name)
        .map_err(|e| anyhow::anyhow!("Failed to import config module {config_module_name}: {e}"))?;
    let config_class = config_module
        .getattr(config_class_name)

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Write config_path as `module.path:ClassName`, e.g. `my_pkg.configs:MyConfig`
  2. If you truly want no config, pass an empty config_path together with empty config instead of a malformed value
  3. Confirm the config class exists in the named module via importlib
  4. Search your config file for `config_path` entries missing `:`

Example fix

// before
config_path = "my_pkg.configs.MyActorConfig"
// after
config_path = "my_pkg.configs:MyActorConfig"
Defensive patterns

Strategy: validation

Validate before calling

import re
if config_path:
    assert re.fullmatch(r"[\w.]+:[\w.]+", config_path), f"bad config_path: {config_path}"

Type guard

def is_valid_config_path(config_path: str) -> bool:
    return ":" in config_path and all(config_path.split(":", 1))

Try / catch

try:
    trader.add_actor_from_importable_config(cfg)
except ValueError as e:
    if "config_path must be in format" in str(e):
        raise ConfigError(f"fix config_path: {cfg.config_path!r}") from e
    raise

Prevention

When it happens

Trigger: Providing a non-empty `config_path` without a colon separator when building an actor or strategy from importable configs — e.g. `my_pkg.configs.MyConfig` instead of `my_pkg.configs:MyConfig`.

Common situations: Same field-name confusion as 1605/1606 but on the config class rather than the actor/strategy class; configs copied from Python dotted-path documentation; YAML/JSON config with dots-only import references.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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