{"record":{"id":"34078d808ee61bc3","repo":"nautechsystems/nautilus_trader","slug":"config-path-must-be-in-format-module-path-classna","errorCode":null,"errorMessage":"config_path must be in format 'module.path:ClassName', was {config_path}","messagePattern":"config_path must be in format 'module\\.path:ClassName', was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/backtest/src/python/node.rs","lineNumber":508,"sourceCode":"        };\n        Ok(component.unbind())\n    })\n    .map_err(to_pyruntime_err)\n}\n\npub(crate) fn create_config_instance<'py>(\n    py: Python<'py>,\n    config_path: &str,\n    config: &HashMap<String, serde_json::Value>,\n) -> anyhow::Result<Option<Bound<'py, PyAny>>> {\n    if config_path.is_empty() && config.is_empty() {\n        log::debug!(\"No config_path or empty config, using None\");\n        return Ok(None);\n    }\n\n    let config_parts: Vec<&str> = config_path.split(':').collect();\n    if config_parts.len() != 2 {\n        anyhow::bail!(\"config_path must be in format 'module.path:ClassName', was {config_path}\");\n    }\n    let (config_module_name, config_class_name) = (config_parts[0], config_parts[1]);\n\n    log::debug!(\n        \"Importing config class from module: {config_module_name} class: {config_class_name}\"\n    );\n\n    let config_module = py\n        .import(config_module_name)\n        .map_err(|e| anyhow::anyhow!(\"Failed to import config module {config_module_name}: {e}\"))?;\n    let config_class = config_module\n        .getattr(config_class_name)\n        .map_err(|e| anyhow::anyhow!(\"Failed to get config class {config_class_name}: {e}\"))?;\n\n    // Convert config dict to Python dict\n    let py_dict = PyDict::new(py);\n\n    for (key, value) in config {","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/python/node.rs#L490-L526","documentation":"create_config_instance imports a config class from Python by splitting config_path on ':'. NautilusTrader importable config paths must have exactly two segments: 'module.path:ClassName'. Any string without exactly one colon (zero colons, or two or more) is rejected.","triggerScenarios":"Passing a config path like 'my_module.MyConfig' (dot instead of colon), 'my.module.Config:Subkey:Extra' (extra colons), or an empty/whitespace path fragment via create_importable_component.","commonSituations":"Copy-pasting a fully-qualified Python class name without converting the last dot to a colon; programmatic config generation producing module:Class:extra; typos in YAML/JSON component config.","solutions":["Rewrite the path to exactly 'module.path:ClassName' — dots in the module, one colon before the class","Strip any extra ':key' suffixes; pass extra data through the config object itself, not the path","Log/inspect the config_path value before calling and validate it with a regex like r'^[\\w.]+:[\\w]+$'"],"exampleFix":"// before\nconfig_path = \"nautilus_trader.examples.strategies.my_strategy:MyStrategyConfig:extra\"\n// after\nconfig_path = \"nautilus_trader.examples.strategies.my_strategy:MyStrategyConfig\"","handlingStrategy":"validation","validationCode":"import re\ndef validate_config_path(path):\n    if not isinstance(path, str) or not re.fullmatch(r\"[\\w.]+:[\\w]+\", path):\n        raise ValueError(f\"config_path must be 'module.path:ClassName', was {path!r}\")\n    return path","typeGuard":"def is_valid_config_path(path) -> bool:\n    return isinstance(path, str) and path.count(':') == 1 and all(path.split(':'))","tryCatchPattern":"try:\n    component = create_importable_component(config_path)\nexcept ValueError as e:\n    log.error(\"Bad config_path %r: %s\", config_path, e)","preventionTips":["Always use one colon between module and class: 'a.b.c:ClassName'","Never embed extra data in the import path; put it in the config object","Validate paths with a regex before persisting configs","Copy fully-qualified names from Python (Class.__module__, Class.__qualname__)"],"tags":["rust","python","config","format"],"backgroundTag":"invalid-argument-format","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"}