{"record":{"id":"a80ad553613e3e7e","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-binancedataclientfactory","errorCode":null,"errorMessage":"Invalid config type for BinanceDataClientFactory. Expected BinanceDataClientConfig, was {config:?}","messagePattern":"Invalid config type for BinanceDataClientFactory\\. Expected BinanceDataClientConfig, was (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/factories.rs","lineNumber":80,"sourceCode":"impl Default for BinanceDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for BinanceDataClientFactory {\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 binance_config = config\n            .as_any()\n            .downcast_ref::<BinanceDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for BinanceDataClientFactory. Expected BinanceDataClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        let client_id = ClientId::from(name);\n\n        binance_config.validate()?;\n\n        let product_type = binance_config.product_type;\n\n        match product_type {\n            BinanceProductType::Spot => {\n                let client = BinanceSpotDataClient::new(client_id, binance_config)?;\n                Ok(Box::new(client))\n            }\n            BinanceProductType::UsdM | BinanceProductType::CoinM => {\n                let client =","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/factories.rs#L62-L98","documentation":"BinanceDataClientFactory::create expects the passed ComponentConfig to be a BinanceDataClientConfig. It performs a downcast_ref and throws this error if the config object is a different type or missing, i.e. the factory was handed a config that does not match the client it builds.","triggerScenarios":"Registering BinanceDataClientFactory with the Node/Kernel but supplying a BinanceLiveExecClientConfig, BinanceClientConfig, or any other config struct (or a config of the wrong adapter, e.g. Bybit) in the clients map for the data client.","commonSituations":"Mixing adapters in a node config so the data client entry points at another adapter's config; renaming/migrating config types across versions and the factory now expects BinanceDataClientConfig; typos in the clients config section.","solutions":["Ensure the data-client entry in the node config uses BinanceDataClientConfig for the factory-named client.","Check that the config key in the clients map matches the name given to BinanceDataClientFactory at registration.","If mixing adapters, verify each factory receives its own adapter's config type.","After an upgrade, update any renamed config types to BinanceDataClientConfig."],"exampleFix":"// before\ndata_clients: { \"BINANCE\": BybitDataClientConfig { .. } }  // wrong adapter config\n// after\ndata_clients: { \"BINANCE\": BinanceDataClientConfig { .. } }","handlingStrategy":"type-guard","validationCode":"// before calling the factory, verify the config type\nfn is_binance_data_config(cfg: &dyn std::any::Any) -> bool {\n    cfg.downcast_ref::<BinanceDataClientConfig>().is_some()\n}","typeGuard":"fn as_binance_data_config(cfg: &dyn std::any::Any) -> Option<&BinanceDataClientConfig> {\n    cfg.downcast_ref::<BinanceDataClientConfig>()\n}","tryCatchPattern":"match factory.create(...) {\n    Ok(client) => { /* use client */ }\n    Err(e) if e.to_string().contains(\"Invalid config type for BinanceDataClientFactory\") => {\n        // inspect the clients map: the config for this client name is not BinanceDataClientConfig\n    }\n    Err(e) => { /* other failure */ }\n}","preventionTips":["Keep one config type per adapter factory; never share a clients-map entry across adapters.","Match client names in the config to the names factories were registered under.","After adapter upgrades, grep configs for renamed config types.","Validate the whole node config at startup so mismatches surface before the node runs."],"tags":["factory","config","type-mismatch","binance"],"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-23T08:17:48.524Z"}