nautechsystems/nautilus_trader · error
Failed to get config class {config_class_name}: {e}
Error message
Failed to get config class {config_class_name}: {e} What it means
Raised when the config module imported successfully but getattr(config_class_name) fails — the named config class is not an attribute of the module (embedded AttributeError). The node cannot build the config instance for the strategy/exec algorithm.
Source
Thrown at crates/live/src/python/node.rs:1800
return Ok(None);
}
let config_parts: Vec<&str> = config_path.split(':').collect();
if config_parts.len() != 2 {
anyhow::bail!("config_path must be in format 'module.path:ClassName', was {config_path}");
}
let (config_module_name, config_class_name) = (config_parts[0], config_parts[1]);
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)
.map_err(|e| anyhow::anyhow!("Failed to get config class {config_class_name}: {e}"))?;
// Convert config dict to Python dict
let py_dict = PyDict::new(py);
for (key, value) in config {
let py_value = config_value_to_py(py, key, value)?;
py_dict.set_item(key, py_value)?;
}
log::debug!("Created config dict: {py_dict:?}");
// Try kwargs first, then default constructor with setattr
let config_instance = match config_class.call((), Some(&py_dict)) {
Ok(instance) => {
log::debug!("Created config instance with kwargs");
instance
}
Err(kwargs_err) => {View on GitHub (pinned to 18893faf8b)
Solutions
- Verify with python -c "from <module> import <config_class_name>"
- Update config_path to the current module:Class name
- Add or use the module that actually defines the config class
- Check __init__.py re-exports if pointing at a package
Example fix
// before config_path="myproj.cfg:StratConfig" # renamed // after config_path="myproj.cfg:StrategyConfig"
Defensive patterns
Strategy: validation
Validate before calling
import importlib
mod, cls = config_path.split(":")
assert hasattr(importlib.import_module(mod), cls), f"{cls} missing from {mod}" Type guard
def config_class_exists(config_path: str) -> bool:
import importlib
mod, cls = config_path.split(":")
return hasattr(importlib.import_module(mod), cls) Try / catch
try:
node.add_strategy_from_config(cfg)
except Exception as e:
if "Failed to get config class" in str(e):
print("Update config_path; class not found:", cfg.config_path)
raise Prevention
- Rename config classes together with their config_path references
- Keep re-exports in package __init__ if pointing at packages
- Validate every config_path in CI before deployment
When it happens
Trigger: config_path "module:Class" where the class name is misspelled, the class was renamed/moved, or the module does not re-export it at top level.
Common situations: Renaming a *Config dataclass during refactor without updating the node config; pointing at the wrong module; expecting a re-export that isn't in __all__/__init__.
Related errors
- Invalid `external_order_claims` type: {e}
- Invalid `external_order_claims` instrument ID {claim}: {e}
- BacktestEngineConfig.controller for importable controller '{
- config_path must be in format 'module.path:ClassName', was {
- Failed to set attribute {key}: {setattr_err}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/9ac55751da8f0cbf.
Report an issue: GitHub.