nautechsystems/nautilus_trader · error
ExecutionAlgorithmConfig must have exec_algorithm_id set
Error message
ExecutionAlgorithmConfig must have exec_algorithm_id set
What it means
ExecutionAlgorithmConfig::new panics via `expect` when the config has no `exec_algorithm_id`, because the algorithm cannot be constructed without an identifier. The type technically allows `None` (probably to satisfy a shared config struct), but this constructor requires it. It is an eager invariant check: fail fast at construction instead of deep inside the actor machinery.
Source
Thrown at crates/trading/src/algorithm/core.rs:145
.field(
"strategy_event_handlers",
&self.strategy_event_handlers.len(),
)
.finish()
}
}
impl ExecutionAlgorithmCore {
/// Creates a new [`ExecutionAlgorithmCore`] instance.
///
/// # Panics
///
/// Panics if `config.exec_algorithm_id` is `None`.
#[must_use]
pub fn new(config: ExecutionAlgorithmConfig) -> Self {
let exec_algorithm_id = config
.exec_algorithm_id
.expect("ExecutionAlgorithmConfig must have exec_algorithm_id set");
let actor_config = DataActorConfig {
actor_id: Some(ActorId::new(exec_algorithm_id.inner())),
log_events: config.log_events,
log_commands: config.log_commands,
};
Self {
actor: DataActorCore::new(actor_config),
config,
exec_algorithm_id,
exec_spawn_ids: AHashMap::new(),
subscribed_strategies: AHashSet::new(),
pending_spawn_reductions: AHashMap::new(),
submit_params: AHashMap::new(),
portfolio: None,
strategy_event_handlers: IndexMap::new(),
}View on GitHub (pinned to 18893faf8b)
Solutions
- Set `exec_algorithm_id: Some(ExecAlgorithmId::from("MY_ALGO"))` (or parse from string) before calling `new`.
- Validate the config at load/deserialization time and reject it with a clear error before reaching this constructor.
- Build the config from a fully-populated source (typed deserialization with required field) rather than partial defaults.
- If the id truly cannot be known yet, defer construction until it is available instead of calling `new` with a placeholder-less config.
Example fix
// before
let config = ExecutionAlgorithmConfig {
exec_algorithm_id: None,
log_events: true,
log_commands: true,
};
let algo = ExecutionAlgorithm::new(config); // panics
// after
let config = ExecutionAlgorithmConfig {
exec_algorithm_id: Some(ExecAlgorithmId::from("EXEC_ALARM")),
log_events: true,
log_commands: true,
};
let algo = ExecutionAlgorithm::new(config); Defensive patterns
Strategy: validation
Validate before calling
// Rust
fn validate_exec_algorithm_config(config: &ExecutionAlgorithmConfig) -> Result<(), String> {
if config.exec_algorithm_id.is_none() {
return Err("exec_algorithm_id is required".to_string());
}
Ok(())
}
validate_exec_algorithm_config(&config)?;
let algo = ExecutionAlgorithm::new(config); Type guard
fn has_exec_algorithm_id(config: &ExecutionAlgorithmConfig) -> bool {
config.exec_algorithm_id.is_some()
} Prevention
- Deserialize configs into types where exec_algorithm_id is required (Option-free) whenever possible.
- Validate all config fields immediately after loading, before constructing any actors.
- Write a unit test that feeds a config with a missing id and asserts your loader rejects it.
When it happens
Trigger: Calling `ExecutionAlgorithmConfig::new(config)` (or `ExecutionAlgorithm::new(config)`) where `config.exec_algorithm_id` is `None` — e.g. building the config programmatically from optional CLI/JSON fields, or deserializing a config file that omitted the `exec_algorithm_id` key.
Common situations: Loading a TOML/JSON execution algorithm config where the id field is optional and missing; constructing a default config before assigning an id; copying config-building code that sets logging flags but never the id; migrating code that used to infer the id elsewhere.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- Invalid factory address for DEX {name} on chain {chain} for
- window limit must be non-zero
- `step` overflows raw quantity units for volume aggregation
- vega pricing timeout exceeds the nanosecond range
- default `StrategyConfig` should be valid
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/e45bd25d63241fdf.
Report an issue: GitHub.