nautechsystems/nautilus_trader · error
Invalid config type for BlockchainExecutionClientFactory. Ex
Error message
Invalid config type for BlockchainExecutionClientFactory. Expected `BlockchainExecutionClientConfig`, was {config:?} What it means
BlockchainExecutionClientFactory.create downcasts the passed config to BlockchainExecutionClientConfig. This error fires when the supplied config object is a different type, so the downcast fails and the factory cannot build the execution client.
Source
Thrown at crates/adapters/blockchain/src/factories.rs:139
impl Default for BlockchainExecutionClientFactory {
fn default() -> Self {
Self::new()
}
}
impl ExecutionClientFactory for BlockchainExecutionClientFactory {
fn create(
&self,
trader_id: TraderId,
name: &str,
config: &dyn ClientConfig,
cache: CacheView,
) -> anyhow::Result<Box<dyn ExecutionClient>> {
let blockchain_execution_config = config
.as_any()
.downcast_ref::<BlockchainExecutionClientConfig>()
.ok_or_else(|| {
anyhow::anyhow!(
"Invalid config type for BlockchainExecutionClientFactory. Expected `BlockchainExecutionClientConfig`, was {config:?}"
)
})?;
let core_execution_client = ExecutionClientCore::new(
trader_id,
ClientId::from(name),
*BLOCKCHAIN_VENUE,
OmsType::Netting,
blockchain_execution_config.client_id,
AccountType::Wallet,
None,
cache,
);
let client = BlockchainExecutionClient::new(
core_execution_client,
blockchain_execution_config.clone(),View on GitHub (pinned to 18893faf8b)
Solutions
- Pass a BlockchainExecutionClientConfig to the execution client factory
- Verify the factory-to-config pairing in the node registration code (data vs execution not swapped)
- Inspect the config's concrete type via its Debug output and correct it
Example fix
// before
let cfg = BlockchainDataClientConfig { .. };
execution_factory.create(trader_id, &cfg, ...)
// after
let cfg = BlockchainExecutionClientConfig { .. };
execution_factory.create(trader_id, &cfg, ...) Defensive patterns
Strategy: type-guard
Validate before calling
if config.as_any().downcast_ref::<BlockchainExecutionClientConfig>().is_none() {
panic!("execution client factory requires BlockchainExecutionClientConfig, got {:?}", config);
} Type guard
fn is_execution_client_config(config: &dyn ClientConfig) -> bool {
config.as_any().downcast_ref::<BlockchainExecutionClientConfig>().is_some()
} Try / catch
let client = execution_factory.create(trader_id, &config, ...)
.map_err(|e| anyhow::anyhow!("execution client factory rejected config: {e:#}"))?; Prevention
- Do not share one config struct between data and execution factories
- Verify factory/config pairing whenever wiring a new node configuration
- Use distinct config type names to avoid copy-paste confusion
When it happens
Trigger: Calling BlockchainExecutionClientFactory.create with a config that is not BlockchainExecutionClientConfig (e.g. a BlockchainDataClientConfig or another adapter's config).
Common situations: Mismatched factory/config pairing in node setup; swapped factories (data factory given the execution config or vice versa); config deserialized into the wrong concrete struct.
Related errors
- Invalid config type for BlockchainDataClientFactory. Expecte
- Invalid config type for DatabentoDataClientFactory. Expected
- Invalid config type for DeribitDataClientFactory. Expected D
- Invalid config type for DeribitExecutionClientFactory. Expec
- Invalid config type for AxExecutionClientFactory. Expected A
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/947964bd2b0b3ee6.
Report an issue: GitHub.