{"record":{"id":"ba4051c499fdc3dc","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-betfairdataclientfactory","errorCode":null,"errorMessage":"Invalid config type for BetfairDataClientFactory. Expected BetfairDataConfig, was {config:?}","messagePattern":"Invalid config type for BetfairDataClientFactory\\. Expected BetfairDataConfig, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/betfair/src/factories.rs","lineNumber":78,"sourceCode":"impl Default for BetfairDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for BetfairDataClientFactory {\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 betfair_config = config\n            .as_any()\n            .downcast_ref::<BetfairDataConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for BetfairDataClientFactory. Expected BetfairDataConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        betfair_config.validate()?;\n\n        let credential = betfair_config.credential()?;\n        let stream_config = betfair_config.stream_config();\n        let nav_filter = betfair_config.navigation_filter();\n        let currency = betfair_config.currency()?;\n        let min_notional = betfair_config.min_notional()?;\n\n        let http_client = BetfairHttpClient::new(\n            credential.clone(),\n            None,\n            None,\n            None,","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/betfair/src/factories.rs#L60-L96","documentation":"BetfairDataClientFactory::create tried to downcast the passed &dyn ClientConfig to BetfairDataConfig and failed — the config object is a different concrete type. This is a bootstrap/wiring error: the TradingNode or custom client setup is constructing the Betfair data client with a config that is not the Betfair-specific one, so creation aborts before any connection is made.","triggerScenarios":"Registering BetfairDataClientFactory in a config map whose entry provides a different config type (e.g. BetfairExecConfig or another venue's config); custom bootstraps that build factories generically and pass the wrong config instance.","commonSituations":"Copy-paste errors in a broker/venue config map pairing the data factory with the wrong config struct; manual client construction mixing data and exec config types.","solutions":["Ensure the config-map entry routed to BetfairDataClientFactory is a BetfairDataConfig instance.","When building clients manually, downcast-check the config before calling create and construct the matching type.","Review the factory-to-config pairing in the TradingNode/routing configuration."],"exampleFix":"// before: map pairs data factory with exec config\nconfig_map.insert(\"BETFAIR\".to_string(), Box::new(BetfairExecConfig::default()));\n\n// after\nconfig_map.insert(\"BETFAIR\".to_string(), Box::new(BetfairDataConfig::default()));","handlingStrategy":"type-guard","validationCode":"let is_valid = config\n    .as_any()\n    .downcast_ref::<BetfairDataConfig>()\n    .is_some();\nif !is_valid {\n    return Err(anyhow::anyhow!(\"expected BetfairDataConfig for data factory\"));\n}","typeGuard":"fn is_betfair_data_config(config: &dyn ClientConfig) -> bool {\n    config.as_any().downcast_ref::<BetfairDataConfig>().is_some()\n}","tryCatchPattern":null,"preventionTips":["Keep venue config maps colocated with factory registrations so pairings are reviewable in one place.","Add a startup smoke test that creates each client factory with its config to catch wiring errors early.","Never share one config instance between data and exec factories."],"tags":["betfair","config","factory","downcast","bootstrap"],"backgroundTag":"config-type-mismatch","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}