{"record":{"id":"4f876674c52fa109","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-blockchaindataclientfactor","errorCode":null,"errorMessage":"Invalid config type for BlockchainDataClientFactory. Expected `BlockchainDataClientConfig`, was {config:?}","messagePattern":"Invalid config type for BlockchainDataClientFactory\\. Expected `BlockchainDataClientConfig`, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/factories.rs","lineNumber":86,"sourceCode":"impl Default for BlockchainDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for BlockchainDataClientFactory {\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 blockchain_config = config\n            .as_any()\n            .downcast_ref::<BlockchainDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for BlockchainDataClientFactory. Expected `BlockchainDataClientConfig`, was {config:?}\"\n                )\n            })?;\n\n        let client = BlockchainDataClient::new(ClientId::from(name), blockchain_config.clone());\n\n        Ok(Box::new(client))\n    }\n\n    fn name(&self) -> &'static str {\n        BLOCKCHAIN\n    }\n\n    fn config_type(&self) -> &'static str {\n        \"BlockchainDataClientConfig\"\n    }\n}\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/factories.rs#L68-L104","documentation":"BlockchainDataClientFactory.create downcasts the passed config object to BlockchainDataClientConfig. This error fires when the config object supplied to the factory is of a different concrete type, so the downcast_ref returns None.","triggerScenarios":"Calling BlockchainDataClientFactory.create (or the node factory registration path) with a config that is not a BlockchainDataClientConfig instance.","commonSituations":"Wiring the factory in a node builder but registering a generic/other client's config (e.g. an execution client config or a hand-rolled config struct); copy-pasted factory registration with the wrong config type; config deserialized into the wrong type.","solutions":["Pass a BlockchainDataClientConfig instance to the data client factory","Check the factory registration: data client factories must be paired with data client configs","Print the config's concrete type and compare with BlockchainDataClientConfig","Fix the config deserialization so it produces BlockchainDataClientConfig"],"exampleFix":"// before\nfactory.create(name, &other_config, ...) // other_config: BlockchainExecutionClientConfig\n// after\nlet config = BlockchainDataClientConfig { /* ... */ };\nfactory.create(name, &config, ...)","handlingStrategy":"type-guard","validationCode":"if config.as_any().downcast_ref::<BlockchainDataClientConfig>().is_none() {\n    panic!(\"data client factory requires BlockchainDataClientConfig, got {:?}\", config);\n}","typeGuard":"fn is_data_client_config(config: &dyn ClientConfig) -> bool {\n    config.as_any().downcast_ref::<BlockchainDataClientConfig>().is_some()\n}","tryCatchPattern":"// wrap factory.create in error context\nlet client = factory.create(name, &config, ...)\n    .map_err(|e| anyhow::anyhow!(\"data client factory rejected config: {e:#}\"))?;","preventionTips":["Pair each factory registration with its matching config type in a single construction site","Name factory/config pairs consistently (DataClientFactory <-> DataClientConfig)","Add a startup smoke test that builds every registered client with its config"],"tags":["factory","downcast","config","rust"],"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-14T00:17:10.932Z"}