{"record":{"id":"e7ee062fa9558449","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-krakenexecutionclientfacto","errorCode":null,"errorMessage":"Invalid config type for KrakenExecutionClientFactory. Expected KrakenExecutionClientConfig, was {config:?}","messagePattern":"Invalid config type for KrakenExecutionClientFactory\\. Expected KrakenExecutionClientConfig, was (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/kraken/src/factories.rs","lineNumber":161,"sourceCode":"impl Default for KrakenExecutionClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl ExecutionClientFactory for KrakenExecutionClientFactory {\n    fn create(\n        &self,\n        trader_id: TraderId,\n        name: &str,\n        config: &dyn ClientConfig,\n        cache: CacheView,\n    ) -> anyhow::Result<Box<dyn ExecutionClient>> {\n        let kraken_config = config\n            .as_any()\n            .downcast_ref::<KrakenExecutionClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for KrakenExecutionClientFactory. Expected KrakenExecutionClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        kraken_config.validate()?;\n\n        let oms_type = OmsType::Netting;\n        let account_type = match kraken_config.product_type {\n            KrakenProductType::Spot => kraken_config.spot_account_type,\n            KrakenProductType::Futures => AccountType::Margin,\n        };\n\n        let client_id = ClientId::from(name);\n        let core = ExecutionClientCore::new(\n            trader_id,\n            client_id,\n            *KRAKEN_VENUE,","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/kraken/src/factories.rs#L143-L179","documentation":"The Kraken execution client factory only accepts a KrakenExecutionClientConfig; it downcasts the generic config passed by the adapter framework and fails with this error when the concrete type does not match. It indicates the factory was registered or invoked with the wrong config object (e.g. a spot config or a different venue's config).","triggerScenarios":"Calling KrakenExecutionClientFactory::create with a config whose as_any() downcast_ref::<KrakenExecutionClientConfig>() returns None — e.g. passing KrakenHttpClientConfig (spot), KrakenFuturesAuthConfig, or a config from another adapter.","commonSituations":"Wiring the spot data config into the futures/execution factory in a LiveNodeConfig; copy-pasted client factory registrations; renaming config types across adapter versions so an old config struct no longer matches.","solutions":["Pass a KrakenExecutionClientConfig (constructed via KrakenExecutionClientConfig::new) to the factory that creates KrakenExecutionClient.","Check the client factory registration in your live node config: the factory and config pair must come from the same adapter module.","If upgrading, verify the config type names in the current kraken adapter version and update your config construction.","Run kraken_config.validate() yourself before create to surface config-field problems separately from type problems."],"exampleFix":"// before\nlet factory = KrakenExecutionClientFactory::new();\nlet client = factory.create(ExecutionClientConfig::Spot(KrakenHttpClientConfig::default()))?;\n// after\nlet config = KrakenExecutionClientConfig::new(\n    trader_id, account_id, api_key, api_secret, None, instrument_provider_config, None,\n)?;\nlet client = factory.create(config)?;","handlingStrategy":"type-guard","validationCode":"if !config.is::<KrakenExecutionClientConfig>() {\n    return Err(anyhow!(\"expected KrakenExecutionClientConfig for Kraken execution factory\"));\n}","typeGuard":"fn as_kraken_exec_config(config: &dyn ClientConfig) -> Option<&KrakenExecutionClientConfig> {\n    config.as_any().downcast_ref::<KrakenExecutionClientConfig>()\n}","tryCatchPattern":null,"preventionTips":["Always build the factory and its config from the same adapter module (kraken).","Write a unit test asserting the accepted config type for each custom factory.","After adapter upgrades, re-verify config struct names used in client wiring."],"tags":["config","downcast","kraken","rust","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"}