{"record":{"id":"d3b7ae9e4b668532","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-axexecutionclientfactory","errorCode":null,"errorMessage":"Invalid config type for AxExecutionClientFactory. Expected AxExecClientConfig, was {config:?}","messagePattern":"Invalid config type for AxExecutionClientFactory\\. Expected AxExecClientConfig, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/factories.rs","lineNumber":192,"sourceCode":"\nimpl Default for AxExecutionClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl ExecutionClientFactory for AxExecutionClientFactory {\n    fn create(\n        &self,\n        name: &str,\n        config: &dyn ClientConfig,\n        cache: CacheView,\n    ) -> anyhow::Result<Box<dyn ExecutionClient>> {\n        let ax_config = config\n            .as_any()\n            .downcast_ref::<AxExecClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for AxExecutionClientFactory. Expected AxExecClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        // AX uses netting for perpetual futures\n        let oms_type = OmsType::Netting;\n        let account_type = AccountType::Margin;\n\n        let core = ExecutionClientCore::new(\n            ax_config.trader_id,\n            ClientId::from(name),\n            *AX_VENUE,\n            oms_type,\n            ax_config.account_id,\n            account_type,\n            None, // base_currency\n            cache,","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/architect_ax/src/factories.rs#L174-L210","documentation":"AxExecutionClientFactory::create downcasts the provided &dyn ClientConfig to AxExecClientConfig and bails when the concrete type differs, printing the actual value. As with the data factory, this arises only from manual factory wiring or a custom FactoryRouter - the normal TradingNode routing always supplies the matching config type (AxExecClientConfig, which also carries trader_id and account settings).","triggerScenarios":"Calling the execution factory's create with AxDataClientConfig, another adapter's config, or a bespoke ClientConfig impl; swapping data/exec configs in hand-written wiring; Python-side passing the wrong nautilus_trader.adapters.architect_ax config class.","commonSituations":"Custom backtest/live harnesses that build clients by hand; refactors that moved factory registration into generic code; copy-paste of a working Binance/Bybit wiring block with configs not renamed.","solutions":["Pass an AxExecClientConfig to AxExecutionClientFactory::create","Prefer TradingNode + routing config so Nautilus pairs factories with their configs for you","Inspect the {config:?} in the message to identify which object was actually passed"],"exampleFix":"# Python, before\nexec_client = AxExecutionClientFactory().create(\n    sweep(data_config)   # wrong class\n)\n# after\nexec_config = AxExecClientConfig()\nexec_client = AxExecutionClientFactory().create(\n    sweep(exec_config)\n)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Rust\nfn is_ax_exec_config(cfg: &dyn ClientConfig) -> bool {\n    cfg.as_any().downcast_ref::<AxExecClientConfig>().is_some()\n}\n# Python\nisinstance(config, AxExecClientConfig)","tryCatchPattern":"match AxExecutionClientFactory.create(name, config, cache) {\n    Err(e) if e.to_string().contains(\"Invalid config type\") => {\n        return Err(e.context(\"passed wrong config to AxExecutionClientFactory; expected AxExecClientConfig\"));\n    }\n    r => r?,\n}","preventionTips":["Use TradingNode and adapter routing instead of hand-wired factories","Name variables data_config/exec_config explicitly; never one generic 'config' for both","Unit-test your factory wiring: each factory receives exactly its own config type"],"tags":["architect-ax","factory","config","type-downcast","execution-client","rust"],"backgroundTag":"invalid-config-type","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}