{"record":{"id":"692dca07f1a68b6a","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-krakendataclientfactory-e","errorCode":null,"errorMessage":"Invalid config type for KrakenDataClientFactory. Expected KrakenDataClientConfig, was {config:?}","messagePattern":"Invalid config type for KrakenDataClientFactory\\. Expected KrakenDataClientConfig, was (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/kraken/src/factories.rs","lineNumber":86,"sourceCode":"impl Default for KrakenDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for KrakenDataClientFactory {\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 kraken_config = config\n            .as_any()\n            .downcast_ref::<KrakenDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for KrakenDataClientFactory. Expected KrakenDataClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        kraken_config.validate()?;\n\n        let client_id = ClientId::from(name);\n\n        match kraken_config.product_type {\n            KrakenProductType::Spot => {\n                let client = KrakenSpotDataClient::new(client_id, kraken_config)?;\n                Ok(Box::new(client))\n            }\n            KrakenProductType::Futures => {\n                let client = KrakenFuturesDataClient::new(client_id, kraken_config)?;\n                Ok(Box::new(client))\n            }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/factories.rs#L68-L104","documentation":"Raised in `KrakenDataClientFactory::create` when the generic `config` handed to the factory cannot be downcast to `KrakenDataClientConfig`. The factory is type-agnostic and relies on the caller passing the exact concrete config type registered for Kraken; anything else fails the `downcast_ref` and this anyhow error names both the expected type and the actual config's Debug representation.","triggerScenarios":"Registering or invoking `KrakenDataClientFactory.create` with a config of another type — e.g. `KrakenExecClientConfig`, a different adapter's data config, or a plain/generic client config object.","commonSituations":"Copy-pasting factory wiring between Kraken data and execution clients and passing the wrong config; registering the factory under a client name whose config type is mismatched in a custom node setup; version changes where config types were renamed/split.","solutions":["Pass a `KrakenDataClientConfig` instance to the data client factory.","Check the `{config:?}` in the message to see which wrong type was actually supplied.","Ensure the data factory is registered with its matching config type and the execution factory with `KrakenExecClientConfig`.","If constructing configs dynamically, downcast/verify the concrete type before calling `create`."],"exampleFix":"// before\nlet data_config = KrakenExecClientConfig { ... };\ndata_factory.create(name, config, Some(venue), Some(instruments), cache, clock)?;\n\n// after\nlet data_config = KrakenDataClientConfig { ... };\ndata_factory.create(name, config, Some(venue), Some(instruments), cache, clock)?;","handlingStrategy":"type-guard","validationCode":"// Rust\nfn is_kraken_data_config(config: &dyn ClientConfig) -> bool {\n    config.as_any().downcast_ref::<KrakenDataClientConfig>().is_some()\n}","typeGuard":"fn as_kraken_data_config(config: &dyn ClientConfig) -> Option<&KrakenDataClientConfig> {\n    config.as_any().downcast_ref::<KrakenDataClientConfig>()\n}","tryCatchPattern":"match as_kraken_data_config(config) {\n    Some(kraken_config) => data_factory.create(name, config, ...)?,\n    None => anyhow::bail!(\"expected KrakenDataClientConfig for KrakenDataClientFactory\"),\n}","preventionTips":["Pair each factory with its exact config type: data factory with KrakenDataClientConfig, exec factory with KrakenExecClientConfig.","Check the {config:?} debug output when this fires to spot copy-pasted wiring.","Add unit tests for node/factory registration that assert config downcasts succeed.","Watch for renames/splits of config types when upgrading adapter versions."],"tags":["kraken","factory","configuration","type-mismatch"],"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"}