{"record":{"id":"3b4abd1b9f3191b9","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-dydxexecutionclientfactory","errorCode":null,"errorMessage":"Invalid config type for DydxExecutionClientFactory. Expected DydxExecutionClientConfig, was {config:?}","messagePattern":"Invalid config type for DydxExecutionClientFactory\\. Expected DydxExecutionClientConfig, was (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/factories.rs","lineNumber":195,"sourceCode":"impl Default for DydxExecutionClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl ExecutionClientFactory for DydxExecutionClientFactory {\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 dydx_config = config\n            .as_any()\n            .downcast_ref::<DydxExecutionClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for DydxExecutionClientFactory. Expected DydxExecutionClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        // dYdX uses netting for perpetual futures\n        let oms_type = OmsType::Netting;\n\n        // dYdX is always margin (perpetual futures)\n        let account_type = AccountType::Margin;\n\n        let core = ExecutionClientCore::new(\n            trader_id,\n            ClientId::from(name),\n            *DYDX_VENUE,\n            oms_type,\n            dydx_config.account_id,\n            account_type,","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/factories.rs#L177-L213","documentation":"DydxExecutionClientFactory::create downcasts the incoming config to DydxExecutionClientConfig. If the config is any other type (e.g. DydxDataClientConfig or another adapter's config), the downcast returns None and this error is raised instead of constructing the execution client.","triggerScenarios":"Calling DydxExecutionClientFactory.create(name, config, cache, ...) with a config object that is not DydxExecutionClientConfig — typically the data client config or a config from a different venue adapter.","commonSituations":"Mixing up config blocks in the trading node YAML/JSON so the execution factory receives the data config; copy-pasting factory wiring code between data and execution client setup; tests asserting the factory rejects wrong configs.","solutions":["Pass a DydxExecutionClientConfig (with wallet key, network, etc.) to DydxExecutionClientFactory.create.","Ensure the node configuration maps the execution-client section to DydxExecutionClientConfig and the data-client section to DydxDataClientConfig.","Construct the config from the dydx adapter's exported config class rather than a generic dict/other adapter class.","Log config.type before calling create to confirm the exact concrete type at runtime."],"exampleFix":"# before\n# exec_config = DydxDataClientConfig(...)  # wrong type\n# factory.create(name, exec_config, cache, ...)\n# after\nexec_config = DydxExecutionClientConfig(dextra_env=..., api_key=..., ...)\nclient = DydxExecutionClientFactory().create(name, exec_config, cache, ...)","handlingStrategy":"type-guard","validationCode":"assert isinstance(config, DydxExecutionClientConfig), f\"expected DydxExecutionClientConfig, got {type(config)}\"","typeGuard":"fn as_dydx_exec_config(config: &dyn ExecutionClientConfig) -> Option<&DydxExecutionClientConfig> {\n    config.as_any().downcast_ref::<DydxExecutionClientConfig>()\n}","tryCatchPattern":"match DydxExecutionClientFactory().create(name, config, cache) {\n    Ok(c) => c,\n    Err(e) if e.to_string().contains(\"Invalid config type\") => {\n        // log config.type and correct the wiring\n        panic!(\"wrong config for execution factory: {e}\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Use DydxExecutionClientConfig for the execution factory only","Verify config.type at startup before calling create","Avoid copy-pasting factory wiring between data and execution setup"],"tags":["dydx","factory","config","downcast","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"}