{"record":{"id":"0dcb33f1ec6505d2","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-axdataclientfactory-expec","errorCode":null,"errorMessage":"Invalid config type for AxDataClientFactory. Expected AxDataClientConfig, was {config:?}","messagePattern":"Invalid config type for AxDataClientFactory\\. Expected AxDataClientConfig, was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/factories.rs","lineNumber":94,"sourceCode":"impl Default for AxDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for AxDataClientFactory {\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 ax_config = config\n            .as_any()\n            .downcast_ref::<AxDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for AxDataClientFactory. Expected AxDataClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        let client_id = ClientId::from(name);\n\n        let http_client = if ax_config.has_api_credentials() {\n            let credential = Credential::resolve(\n                ax_config.api_key.clone().map(|value| value.into_inner()),\n                ax_config.api_secret.clone().map(|value| value.into_inner()),\n            )\n            .ok_or_else(|| anyhow::anyhow!(\"API credentials not configured\"))?;\n\n            AxHttpClient::with_credentials(\n                credential.api_key().to_string(),\n                credential.api_secret().to_string(),\n                Some(ax_config.http_base_url()),","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/factories.rs#L76-L112","documentation":"AxDataClientFactory::create downcasts the generic client config to `AxDataClientConfig`; if the passed config is any other type the factory cannot build an AX data client and raises this error including the debug representation of the received config. It is a factory/type-mismatch guard, not a network problem.","triggerScenarios":"Calling `AxDataClientFactory.create(name, config, ...)` with a config object that is not an `AxDataClientConfig` — e.g. an `AxExecutionClientConfig`, another venue's data config, or a generic `DataClientConfig`.","commonSituations":"Registering the AX data factory but passing the execution client's config; wiring configs by position/variable name in a multi-venue setup; copying config-construction code from another adapter.","solutions":["Construct and pass an `AxDataClientConfig` to the AX data factory.","Check that the config registered for this factory name is the AX data config, not the execution config.","Read the `{config:?}` in the message to see which type was actually passed and fix the wiring.","If configs are built generically, add a match/downcast step that routes each config to its matching factory."],"exampleFix":"// before\nlet data_config = AxExecutionClientConfig { ... };\nfactory.create(name, data_config, ...)?; // wrong type\n\n// after\nlet data_config = AxDataClientConfig {\n    api_key: Some(api_key),\n    instrument_provider: InstrumentProviderConfig::load(true),\n    http_base_url: None,\n    ..Default::default()\n};\nfactory.create(name, data_config, ...)?;","handlingStrategy":"type-guard","validationCode":"// before calling the factory\nlet Some(_) = config.as_any().downcast_ref::<AxDataClientConfig>() else {\n    panic!(\"config passed to AxDataClientFactory must be AxDataClientConfig\");\n};","typeGuard":"fn as_ax_data_config(config: &dyn Any) -> Option<&AxDataClientConfig> {\n    config.downcast_ref::<AxDataClientConfig>()\n}","tryCatchPattern":"match factory.create(name, config, ...) {\n    Ok(client) => client,\n    Err(e) if e.to_string().contains(\"Invalid config type for AxDataClientFactory\") => {\n        return Err(anyhow::anyhow!(\"wiring mistake: pass AxDataClientConfig, got: {e}\"));\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Build each config with its concrete struct type next to its factory call.","Name config variables after their factory (e.g. `ax_data_config`).","Unit-test the bootstrap wiring so wrong configs fail at test time.","Log `config:?` type names during setup in debug builds."],"tags":["configuration","type-mismatch","factory","rust"],"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-23T08:17:48.524Z"}