{"record":{"id":"dc75c4ceec1d72b7","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-derivedataclientfactory-e","errorCode":null,"errorMessage":"Invalid config type for DeriveDataClientFactory. Expected DeriveDataClientConfig, was {config:?}","messagePattern":"Invalid config type for DeriveDataClientFactory\\. Expected DeriveDataClientConfig, was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/derive/src/factories.rs","lineNumber":88,"sourceCode":"impl Default for DeriveDataClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl DataClientFactory for DeriveDataClientFactory {\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 derive_config = config\n            .as_any()\n            .downcast_ref::<DeriveDataClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for DeriveDataClientFactory. Expected DeriveDataClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        let client = DeriveDataClient::new(ClientId::from(name), derive_config)?;\n        Ok(Box::new(client))\n    }\n\n    fn name(&self) -> &'static str {\n        DERIVE\n    }\n\n    fn config_type(&self) -> &'static str {\n        stringify!(DeriveDataClientConfig)\n    }\n}\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/derive/src/factories.rs#L70-L106","documentation":"DeriveDataClientFactory::create downcasts the generic config to DeriveDataClientConfig. If the supplied config is any other type, the downcast fails and the factory raises this error, echoing the debug representation of the wrong config. Factories are type-safe dispatchers: the Derive data factory only builds clients from Derive data configs.","triggerScenarios":"Registering or invoking DeriveDataClientFactory with a config object of another adapter's type (e.g. a Binance or DeriveExecClientConfig), or with a plain/placeholder config struct.","commonSituations":"Wiring clients in a live node where factory/config pairs got mismatched; copy-pasted factory registration code; passing an execution config where a data config is expected.","solutions":["Pass a DeriveDataClientConfig instance to DeriveDataClientFactory; check the config type in the error's {config:?} output.","Fix the factory-to-config pairing in your node wiring so each factory gets its own config type.","If building configs from TOML/JSON, ensure the config section deserializes into DeriveDataClientConfig.","Verify you are not confusing DeriveDataClientFactory with DeriveExecClientFactory (which expects the exec config)."],"exampleFix":"// before\nfactory.create(name, DeriveExecClientConfig { .. })?; // wrong config type\n// after\nfactory.create(name, DeriveDataClientConfig { .. })?;","handlingStrategy":"type-guard","validationCode":"fn is_derive_data_config(cfg: &dyn AnyConfigLike) -> bool {\n    cfg.as_any().downcast_ref::<DeriveDataClientConfig>().is_some()\n}","typeGuard":"fn as_derive_data_config(cfg: &dyn ClientConfig) -> Option<&DeriveDataClientConfig> {\n    cfg.as_any().downcast_ref::<DeriveDataClientConfig>()\n}","tryCatchPattern":"match factory.create(name, config) {\n    Ok(client) => /* use client */,\n    Err(e) if e.to_string().contains(\"Invalid config type\") => {\n        // inspect {config:?} in the message and fix the factory/config pairing\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Pair each factory with its exact config type during node wiring","Distinguish data vs exec factories/configs (DeriveDataClientConfig vs exec config)","Validate config types at startup before registering clients","Log config debug output when wiring to catch mismatches early"],"tags":["derive","factory","config","type-mismatch","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-14T05:17:10.506Z"}