{"record":{"id":"d2ee4b66c74bae23","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-lighterexecutionclientfact","errorCode":null,"errorMessage":"Invalid config type for LighterExecutionClientFactory. Expected LighterExecutionClientConfig, was {config:?}","messagePattern":"Invalid config type for LighterExecutionClientFactory\\. Expected LighterExecutionClientConfig, was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/factories.rs","lineNumber":135,"sourceCode":"    #[must_use]\n    pub const fn new() -> Self {\n        Self\n    }\n}\n\nimpl ExecutionClientFactory for LighterExecutionClientFactory {\n    fn create(\n        &self,\n        trader_id: TraderId,\n        name: &str,\n        config: &dyn ClientConfig,\n        cache: CacheView,\n    ) -> anyhow::Result<Box<dyn ExecutionClient>> {\n        let lighter_config = config\n            .as_any()\n            .downcast_ref::<LighterExecutionClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for LighterExecutionClientFactory. Expected LighterExecutionClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        // Lighter is a perpetual futures DEX with margin accounts and one\n        // position per market on the L2.\n        let core = ExecutionClientCore::new(\n            trader_id,\n            ClientId::from(name),\n            lighter_config.resolved_venue(),\n            OmsType::Netting,\n            lighter_config.account_id,\n            AccountType::Margin,\n            None,\n            cache,\n        );\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/factories.rs#L117-L153","documentation":"This error is thrown by LighterExecutionClientFactory::create when the config passed to the factory is not a LighterExecutionClientConfig. The factory downcasts the generic config to the concrete config type and fails fast with anyhow if the downcast returns None, embedding the actual config in Debug form. It exists to catch wiring mistakes between data/exec client factories and their configs.","triggerScenarios":"Calling LighterExecutionClientFactory::create with any config other than LighterExecutionClientConfig — e.g. passing a LighterDataClientConfig, another venue's ExecutionClientConfig, or a default/generic config struct into create().","commonSituations":"Miswiring in a node/trading config where the execution client config is built from the wrong venue section; copy-pasting factory registration code and pairing a factory with the wrong config type; tests constructing a client with the data config by mistake.","solutions":["Construct and pass a LighterExecutionClientConfig (with api_key, private key/account details, etc.) to the factory's create()","Check which factory is being invoked and ensure the registered config type matches the adapter (Lighter)","Print the included {config:?} fragment to see the actual concrete config type that was supplied","Verify config deserialization routed the venue-specific fields to the Lighter execution config, not the data config"],"exampleFix":"// before\nlet client = LighterExecutionClientFactory.create(&lighter_data_config, ...)?;\n// after\nlet exec_config = LighterExecutionClientConfig { /* from the 'lighter' execution section */ };\nlet client = LighterExecutionClientFactory.create(&exec_config, ...)?;","handlingStrategy":"type-guard","validationCode":"fn ensure_lighter_exec_config(cfg: &dyn std::any::Any) -> Option<&LighterExecutionClientConfig> {\n    cfg.downcast_ref::<LighterExecutionClientConfig>()\n}","typeGuard":"fn is_lighter_exec_config(cfg: &dyn std::any::Any) -> bool {\n    cfg.downcast_ref::<LighterExecutionClientConfig>().is_some()\n}","tryCatchPattern":"match config.as_any().downcast_ref::<LighterExecutionClientConfig>() {\n    Some(c) => build_client(c),\n    None => return Err(anyhow::anyhow!(\"expected LighterExecutionClientConfig, got {config:?}\")),\n}","preventionTips":["Pair each adapter factory with its matching config type when wiring clients","Derive execution and data configs from the same venue section of the node config","Add a unit test that creates each factory with both its own and a foreign config to catch mismatches"],"tags":["rust","config","adapter","downcast"],"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"}