{"record":{"id":"cbcce447d7537f62","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-tardisdataclientfactory-e","errorCode":null,"errorMessage":"Invalid config type for TardisDataClientFactory. Expected TardisDataClientConfig, was {config:?}","messagePattern":"Invalid config type for TardisDataClientFactory\\. Expected TardisDataClientConfig, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/tardis/src/factories.rs","lineNumber":74,"sourceCode":"impl Default for TardisDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for TardisDataClientFactory {\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 tardis_config = config\n            .as_any()\n            .downcast_ref::<TardisDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for TardisDataClientFactory. \\\n                     Expected TardisDataClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        let client_id = ClientId::from(name);\n        let client = TardisDataClient::new(client_id, tardis_config)?;\n        Ok(Box::new(client))\n    }\n\n    fn name(&self) -> &'static str {\n        TARDIS\n    }\n\n    fn config_type(&self) -> &'static str {\n        \"TardisDataClientConfig\"\n    }","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/tardis/src/factories.rs#L56-L92","documentation":"Raised in TardisDataClientFactory::create when the passed config object cannot be downcast to TardisDataClientConfig. The factory was given a config type built for a different adapter, indicating a factory/config mismatch in client registration.","triggerScenarios":"Calling create with a config whose as_any().downcast_ref::<TardisDataClientConfig>() returns None — e.g. a BinanceDataClientConfig or any other client config passed to this factory.","commonSituations":"Registering factories and configs in the wrong order; a typo pairing the wrong factory with a config; building clients from a mixed config list; using an older config struct after an adapter refactor.","solutions":["Pass a TardisDataClientConfig to TardisDataClientFactory; check which factory is paired with each config.","Verify the config was constructed with the Tardis adapter's builder, not another adapter's.","Check that you're not iterating a shared config list against a single factory.","After an adapter version upgrade, rebuild configs with the matching adapter version."],"exampleFix":"// before\nlet data_client = tardis_factory.create(binance_config, ...)?;\n// after\nlet data_client = tardis_factory.create(tardis_data_config, ...)?;","handlingStrategy":"type-guard","validationCode":"// Match each config to its factory by name before create\nanyhow::ensure!(\n    config.as_any().is::<TardisDataClientConfig>(),\n    \"pass TardisDataClientConfig to TardisDataClientFactory\"\n);","typeGuard":"fn is_tardis_config(config: &dyn UserConfig) -> bool {\n    config.as_any().downcast_ref::<TardisDataClientConfig>().is_some()\n}","tryCatchPattern":"let client = factory.create(config, ...)\n    .map_err(|e| if e.to_string().contains(\"Invalid config type for TardisDataClientFactory\") {\n        anyhow::anyhow!(\"factory/config mispairing: {e}\")\n    } else { e })?;","preventionTips":["Pair each factory with its matching config type explicitly.","Build configs via each adapter's own builder, not ad-hoc structs.","When iterating configs, look up the factory by adapter name instead of using a single factory."],"tags":["factory","downcast","config"],"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"}