{"record":{"id":"2412d1adccca3854","repo":"nautechsystems/nautilus_trader","slug":"backtestengineconfig-controller-for-importable-con","errorCode":null,"errorMessage":"BacktestEngineConfig.controller for importable controller '{}' requires the python feature","messagePattern":"BacktestEngineConfig\\.controller for importable controller '(.+?)' requires the python feature","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/backtest/src/engine.rs","lineNumber":155,"sourceCode":"    ///\n    /// # Errors\n    ///\n    /// Returns an error if the core `NautilusKernel` fails to initialize.\n    pub fn new(mut config: BacktestEngineConfig) -> anyhow::Result<Self> {\n        // The engine does not replay `add_instrument` on reset, so reruns rely\n        // on the cache retaining instruments regardless of the caller's config.\n        let mut cache_config = config.cache.unwrap_or_default();\n        cache_config.drop_instruments_on_reset = false;\n        config.cache = Some(cache_config);\n        let kernel = NautilusKernel::new(\"BacktestEngine\".to_string(), config.clone())?;\n        let instance_id = kernel.instance_id;\n        #[cfg(feature = \"python\")]\n        if let Some(controller) = config.controller.as_ref() {\n            Trader::add_controller_from_importable_config(&kernel.trader, controller)?;\n        }\n        #[cfg(not(feature = \"python\"))]\n        if let Some(controller) = config.controller.as_ref() {\n            anyhow::bail!(\n                \"BacktestEngineConfig.controller for importable controller '{}' requires the python feature\",\n                controller.controller_path\n            );\n        }\n\n        Ok(Self {\n            kernel,\n            instance_id,\n            config,\n            accumulator: TimeEventAccumulator::new(),\n            run_config_id: None,\n            run_id: None,\n            venues: IndexMap::new(),\n            exec_clients: Vec::new(),\n            has_data: AHashSet::new(),\n            has_book_data: AHashSet::new(),\n            has_book_processed: AHashSet::new(),\n            data_iterator: BacktestDataIterator::new(),","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/backtest/src/engine.rs#L137-L173","documentation":"BacktestEngineConfig supports an importable Python controller, but wiring one requires the crate's `python` feature. When the engine is built without Python bindings and a controller is configured, construction fails with this error instead of silently ignoring the controller.","triggerScenarios":"Constructing a BacktestEngine with config.controller set to Some(ImportableControllerConfig{..}) while the nautilus crate was compiled without the `python` feature (e.g. a pure-Rust build).","commonSituations":"Using a config file generated from a Python environment in a Rust-only binary; enabling the controller field by default in shared config tooling; a build without `--features python`.","solutions":["Rebuild with the python feature enabled (e.g. `cargo build --features python`)","Remove `controller` from the BacktestEngineConfig for Rust-only builds","Conditionally set the controller in config loading based on build features","Use a Rust-native controller implementation if available instead of the importable Python one"],"exampleFix":"// before\nlet engine = BacktestEngine::new(Some(config_with_controller), None)?;  // no python feature\n// after\ncargo build --features python\n// or remove the controller:\nconfig.controller = None;","handlingStrategy":"validation","validationCode":"#[cfg(not(feature = \"python\"))]\nif config.controller.is_some() {\n    panic!(\"controller configured but built without the python feature\");\n}","typeGuard":null,"tryCatchPattern":"let engine = BacktestEngine::new(Some(config), None)\n    .map_err(|e| if e.to_string().contains(\"requires the python feature\") {\n        anyhow::anyhow!(\"Rebuild with --features python or drop config.controller\")\n    } else { e })?;","preventionTips":["Keep controller settings out of shared configs used by Rust-only builds","Document feature requirements next to config fields","Verify feature flags in build scripts/CI matrices"],"tags":["feature-flag","python","config","backtest"],"backgroundTag":"feature-not-enabled","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"}