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 by `create_config_instance` when the config module imported successfully but `getattr` cannot find the named config class on it. The referenced config class does not exist under that name in that module.
Source
Thrown at crates/system/src/python/registration.rs:582
};
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)
.map_err(|e| anyhow::anyhow!("Failed to get config class {config_class_name}: {e}"))?;
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)?;
}
let config_instance = match config_class.call((), Some(&py_dict)) {
Ok(instance) => instance,
Err(kwargs_err) => match config_class.call0() {
Ok(instance) => {
for (key, value) in config {
let py_value = config_value_to_py(py, key, value)?;
if let Err(setattr_err) = instance.setattr(key, py_value) {
anyhow::bail!("Failed to set attribute {key}: {setattr_err}");
}
}View on GitHub (pinned to 18893faf8b)
Solutions
- Confirm the config class name matches its definition in the module
- Re-export the class at the module's top level or update the config path
- Grep the module for `class <Name>` to find the correct current name
Example fix
// before config_path = "my_package.config:MyActorConf" // after config_path = "my_package.config:MyActorConfig"
Defensive patterns
Strategy: validation
Validate before calling
from importlib import import_module
mod_path, cls = config_path.split(":")
assert hasattr(import_module(mod_path), cls), f"no config class {cls} in {mod_path}" Try / catch
try:
trader.add_actor(actor_config)
except Exception as e:
if "Failed to get config class" in str(e):
logging.error("verify config class name: %s", e)
raise Prevention
- Match config class names exactly as defined in source
- Re-export config classes from stable module paths
- Avoid referring to nested classes in config paths
When it happens
Trigger: A `config_path` of the form `module:ConfigClass` where the config class is misspelled, was renamed, or lives in a different module than specified while instantiating a Python actor/strategy config.
Common situations: Renaming `*Config` dataclasses during refactors with stale configs pointing at old names; referring to an inner/non-top-level class; case mismatch.
Related errors
- Failed to get class {class_name}: {e}
- 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 {
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/79b72dd15486e9f5.
Report an issue: GitHub.