{"record":{"id":"01311ab6bdb3c128","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-coinbasedataclientfactory","errorCode":null,"errorMessage":"Invalid config type for CoinbaseDataClientFactory. Expected CoinbaseDataClientConfig, was {config:?}","messagePattern":"Invalid config type for CoinbaseDataClientFactory\\. Expected CoinbaseDataClientConfig, was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/coinbase/src/factories.rs","lineNumber":91,"sourceCode":"impl Default for CoinbaseDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for CoinbaseDataClientFactory {\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 coinbase_config = config\n            .as_any()\n            .downcast_ref::<CoinbaseDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for CoinbaseDataClientFactory. Expected CoinbaseDataClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        let client_id = ClientId::from(name);\n        let client = CoinbaseDataClient::new(client_id, coinbase_config)?;\n        Ok(Box::new(client))\n    }\n\n    fn name(&self) -> &'static str {\n        COINBASE\n    }\n\n    fn config_type(&self) -> &'static str {\n        \"CoinbaseDataClientConfig\"\n    }\n}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/coinbase/src/factories.rs#L73-L109","documentation":"CoinbaseDataClientFactory::create downcasts the generic ClientConfig to CoinbaseDataClientConfig; if the downcast fails it rejects the config with this error. It is a type-safety guard ensuring the factory only builds Coinbase data clients from matching config types.","triggerScenarios":"Registering the Coinbase data factory but passing a different config type (e.g. CoinbaseExecutionClientConfig or another venue's config) to create(), or tests that deliberately pass a wrong config type.","commonSituations":"Mixing up data vs execution config in a node config file, wiring the wrong factory to the wrong config section, or renaming/moving config types after an adapter upgrade.","solutions":["Pass a CoinbaseDataClientConfig instance to the data factory's create().","Check your node/trading config file that the data-client section uses the Coinbase data client config schema.","Verify factory registration pairs the correct config type with the correct factory.","After upgrading nautilus, re-check config struct names for renames in the coinbase adapter."],"exampleFix":"// before\nfactory.create(name, &coinbase_exec_config, ...)?;\n// after\nlet data_config = CoinbaseDataClientConfig::from(coinbase_exec_config.clone());\nfactory.create(name, &data_config, ...)?;","handlingStrategy":"type-guard","validationCode":"let is_data_cfg = config.as_any().downcast_ref::<CoinbaseDataClientConfig>().is_some();\nif !is_data_cfg { /* route to execution factory or fix config wiring */ }","typeGuard":"fn is_coinbase_data_config(config: &dyn ClientConfig) -> bool {\n    config.as_any().downcast_ref::<CoinbaseDataClientConfig>().is_some()\n}","tryCatchPattern":"match factory.create(name, config, ...) {\n    Ok(c) => c,\n    Err(e) if e.to_string().contains(\"Invalid config type for CoinbaseDataClientFactory\") => bail!(\"wired wrong config type to data factory: {e}\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Keep data and execution config sections in separate, clearly named config blocks.","Unit-test factory wiring with each config type you ship.","Check for adapter renames after nautilus upgrades."],"tags":["config","downcast","type-mismatch","factory"],"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"}