{"record":{"id":"29bc89f91faea797","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-databentodataclientfactory","errorCode":null,"errorMessage":"Invalid config type for DatabentoDataClientFactory. Expected DatabentoDataClientConfig, was {config:?}","messagePattern":"Invalid config type for DatabentoDataClientFactory\\. Expected DatabentoDataClientConfig, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/databento/src/factories.rs","lineNumber":120,"sourceCode":"impl Default for DatabentoDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for DatabentoDataClientFactory {\n    fn create(\n        &self,\n        name: &str,\n        config: &dyn ClientConfig,\n        _cache: CacheView,\n        _clock: Rc<RefCell<dyn Clock>>,\n    ) -> anyhow::Result<Box<dyn DataClient>> {\n        let databento_config = config\n            .as_any()\n            .downcast_ref::<DatabentoDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for DatabentoDataClientFactory. Expected DatabentoDataClientConfig, was {config:?}\"\n                )\n            })?\n            .clone();\n\n        let client_id = ClientId::from(name);\n        let client =\n            DatabentoDataClient::new(client_id, databento_config, get_atomic_clock_realtime())?;\n        Ok(Box::new(client))\n    }\n\n    fn name(&self) -> &'static str {\n        DATABENTO\n    }\n\n    fn config_type(&self) -> &'static str {\n        \"DatabentoDataClientConfig\"\n    }","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/databento/src/factories.rs#L102-L138","documentation":"DatabentoDataClientFactory::create receives a generic config object and downcasts it to DatabentoDataClientConfig. If the caller passed a different config type (any other client's config or a plain config), the downcast fails and this error names both the expected type and the actual config's debug representation.","triggerScenarios":"Calling DataClientFactory.create (or get_data_client through the client registration machinery) with a config that is not a DatabentoDataClientConfig — e.g. passing DatabentoExecClientConfig, another venue's DataClientConfig, or a constructed base config.","commonSituations":"Wiring a trading node where the config map is keyed by client name but the config objects are mismatched; copy-pasted factory registration with the wrong config type; programmatic client building mixing adapter configs.","solutions":["Ensure the config passed to the Databento factory is constructed via DatabentoDataClientConfig (or its builder)","Check that each adapter's factory is paired with its matching config type in the node config","Print the config's debug output (included in the error) to identify the actual type passed","Fix client-name to config mapping in the trading node configuration"],"exampleFix":"// before\nlet client = data_factory.create(\"Databento\", &base_data_client_config, &logger, &clock)?;\n// after\nlet cfg = DatabentoDataClientConfig::builder().api_key(key)?.publishers_filepath(path)?.build()?;\nlet client = data_factory.create(\"Databento\", &cfg, &logger, &clock)?;","handlingStrategy":"type-guard","validationCode":"// Rust\ncfg.as_any().downcast_ref::<DatabentoDataClientConfig>().is_some()","typeGuard":null,"tryCatchPattern":"// Rust\nErr(e) => error!(\"wrong config: {e:#}\"),","preventionTips":["Match factory and config types","Check node config mappings","Use typed builders","Read debug output"],"tags":["rust","factory","downcast","config"],"backgroundTag":"config-type-mismatch","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"}