{"record":{"id":"d4c766a7f051dd32","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-bitmexdataclientfactory-e","errorCode":null,"errorMessage":"Invalid config type for BitmexDataClientFactory. Expected BitmexDataClientConfig, was {config:?}","messagePattern":"Invalid config type for BitmexDataClientFactory\\. Expected BitmexDataClientConfig, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/factories.rs","lineNumber":89,"sourceCode":"impl Default for BitmexDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for BitmexDataClientFactory {\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 bitmex_config = config\n            .as_any()\n            .downcast_ref::<BitmexDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for BitmexDataClientFactory. Expected BitmexDataClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        let client_id = ClientId::from(name);\n        let client = BitmexDataClient::new(client_id, bitmex_config)?;\n        Ok(Box::new(client))\n    }\n\n    fn name(&self) -> &'static str {\n        BITMEX\n    }\n\n    fn config_type(&self) -> &'static str {\n        \"BitmexDataClientConfig\"\n    }\n}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/factories.rs#L71-L107","documentation":"BitmexDataClientFactory::create only accepts a config object that downcasts to BitmexDataClientConfig. Any other config type passed to the factory produces this error naming both the expected type and the actual config value.","triggerScenarios":"Calling create on BitmexDataClientFactory with a config whose as_any().downcast_ref::<BitmexDataClientConfig>() returns None — e.g. passing BitmexExecutionClientConfig, a generic client config, or a config built for another venue.","commonSituations":"Registering the data client factory with the wrong config in a node config file, copy-pasting execution client config into the data client slot, or using a renamed/moved config struct after a version upgrade.","solutions":["Pass a BitmexDataClientConfig instance to BitmexDataClientFactory::create.","Check the config section of your node/trading config maps to the data client, not the execution client.","Rebuild the config via the factory's expected type or a deserialization into BitmexDataClientConfig.","Compare the debug output in the message (was {config:?}) against the expected struct to spot the mismatch."],"exampleFix":"// before\nlet config = BitmexExecutionClientConfig { ... };\nlet client = BitmexDataClientFactory.create(name, config, ...);\n// after\nlet config = BitmexDataClientConfig { api_key, api_secret, ... };\nlet client = BitmexDataClientFactory.create(name, config, ...);","handlingStrategy":"type-guard","validationCode":"// Rust\nfn is_bitmex_data_config(config: &dyn Any) -> bool {\n    config.downcast_ref::<BitmexDataClientConfig>().is_some()\n}","typeGuard":"// Rust\nfn as_bitmex_data_config(config: &dyn Any) -> Option<&BitmexDataClientConfig> {\n    config.downcast_ref::<BitmexDataClientConfig>()\n}","tryCatchPattern":"// Rust\nlet cfg = config.as_any()\n    .downcast_ref::<BitmexDataClientConfig>()\n    .ok_or_else(|| anyhow::anyhow!(\"expected BitmexDataClientConfig, got {:?}\", config))?;","preventionTips":["Keep data vs execution client config sections separate in node configs","Rely on typed deserialization instead of hand-built configs","Double-check factory/config pairing when wiring adapters"],"tags":["config","downcast","factory","bitmex"],"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"}