nautechsystems/nautilus_trader · error · anyhow::Error
Failed to resolve {filter_callable}: {e}
Error message
Failed to resolve {filter_callable}: {e} What it means
The module imported successfully but getattr(callable_name) failed, so the named attribute does not exist on the module (or is not accessible). The error wraps the Python AttributeError with the original filter_callable for context.
Source
Thrown at crates/adapters/interactive_brokers/src/providers/instruments.rs:1792
return Ok(true);
};
#[cfg(feature = "python")]
{
use nautilus_model::python::instruments::instrument_any_to_pyobject;
use pyo3::{prelude::*, types::PyModule};
Python::attach(|py| {
let (module_name, callable_name) =
filter_callable.rsplit_once('.').ok_or_else(|| {
anyhow::anyhow!(
"Invalid filter_callable path {filter_callable:?}; expected module.callable"
)
})?;
let callable = PyModule::import(py, module_name)
.map_err(|e| anyhow::anyhow!("Failed to import {module_name}: {e}"))?
.getattr(callable_name)
.map_err(|e| anyhow::anyhow!("Failed to resolve {filter_callable}: {e}"))?;
let py_instrument = instrument_any_to_pyobject(py, instrument.clone())
.map_err(|e| anyhow::anyhow!("Failed to convert instrument to Python: {e}"))?;
callable
.call1((py_instrument,))
.and_then(|result| result.extract::<bool>())
.map_err(|e| anyhow::anyhow!("filter_callable {filter_callable} failed: {e}"))
})
}
#[cfg(not(feature = "python"))]
{
let _ = instrument;
anyhow::bail!(
"filter_callable {filter_callable:?} requires the Interactive Brokers adapter to be built with the python feature"
);
}
}
View on GitHub (pinned to 18893faf8b)
Solutions
- Verify the attribute exists: 'python -c "import m; print(m.<callable_name>)"'
- Fix spelling/casing in the filter_callable string to match the actual function name
- Update the path after any rename/refactor of the filter module
Example fix
// before filter_callable = "mypackage.filters.skipFX" // after filter_callable = "mypackage.filters.skip_fx"
Defensive patterns
Strategy: validation
Validate before calling
import importlib
mod = importlib.import_module(module_name)
assert callable(getattr(mod, func_name)), f"{filter_callable} is not callable" Type guard
fn check(mod: &str, func: &str) { debug_assert!(PY_MODS.get(mod).map(|m| m.has_attr(func)).unwrap_or(false)); } Try / catch
try:
process_contract_detail(details, filter_callable)
except Exception as e:
if "Failed to resolve" in str(e):
print("callable renamed or missing:", e)
else:
raise Prevention
- Verify the attribute exists on the module after any rename/refactor
- Use a smoke test that resolves every configured filter_callable at startup
- Match exact spelling and casing of the function name
When it happens
Trigger: filter_callable points at a module where the function name is misspelled, renamed, or the name refers to a non-callable attribute; e.g. 'mypackage.filters.skipFX' when the function is 'skip_fx'.
Common situations: Version drift — the callable was renamed or moved to another module; case-sensitivity mistakes; passing a class or variable instead of a function.
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
- Invalid filter_callable path {filter_callable:?}; expected m
- Failed to import {module_name}: {e}
- Failed to get config class {config_class_name}: {e}
- Chain ID mismatch at connect: expected {expected_chain_id},
- Invalid `external_order_claims` type: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/1aa86ba57b0ed08c.
Report an issue: GitHub.