nautechsystems/nautilus_trader · error
No client registered with ID {client_id}
Error message
No client registered with ID {client_id} What it means
set_default_client validates that the requested client ID exists in the engine's clients map. This error is raised when you try to set a default client that has never been registered via register_client.
Source
Thrown at crates/execution/src/engine/mod.rs:400
self.clients.insert(client_id, adapter);
self.default_client_id = Some(client_id);
log::debug!("Registered default client {client_id}");
}
/// Marks an already-registered client as the default for fallback routing.
///
/// # Errors
///
/// Returns an error if no client is registered with the given ID, or a default
/// client has already been set.
pub fn set_default_client(&mut self, client_id: ClientId) -> anyhow::Result<()> {
if self.default_client_id.is_some() {
anyhow::bail!("default client already registered");
}
if !self.clients.contains_key(&client_id) {
anyhow::bail!("No client registered with ID {client_id}");
}
self.default_client_id = Some(client_id);
log::debug!("Set client {client_id} as default");
Ok(())
}
#[must_use]
/// Returns a reference to the execution client registered with the given ID.
pub fn get_client(&self, client_id: &ClientId) -> Option<&dyn ExecutionClient> {
self.clients.get(client_id).map(|a| a.client.as_ref())
}
#[must_use]
/// Returns a mutable reference to the execution client adapter registered with the given ID.
pub fn get_client_adapter_mut(
&mut self,
client_id: &ClientId,
) -> Option<&mut ExecutionClientAdapter> {View on GitHub (pinned to 18893faf8b)
Solutions
- Register the client with register_client before calling set_default_client.
- Verify the ClientId matches exactly the one used at registration (ClientIds are compared exactly).
- Reorder startup code so client registration precedes default assignment.
- Check whether the client was deregistered earlier in the flow and re-register it.
Example fix
// before
engine.set_default_client("BINANCE".into())?; // never registered
// after
engine.register_client(binance_client)?;
engine.set_default_client(binance_client.id().clone())?; Defensive patterns
Strategy: validation
Validate before calling
// ensure the client exists before setting it as default
assert!(engine.get_client_adapter(&client_id).is_some(), "client {client_id} not registered");
engine.set_default_client(client_id)?; Try / catch
match engine.set_default_client(id) {
Err(e) if e.to_string().contains("No client registered") => register_client_then_retry(),
other => other?,
} Prevention
- Always call register_client before set_default_client.
- Source ClientIds from the registered adapter's own id() rather than hand-written strings.
- Watch for ID casing/typo mismatches between config and registration.
When it happens
Trigger: Calling ExecutionEngine::set_default_client with a ClientId that is not a key of self.clients — i.e. the client was never registered, or was deregistered beforehand.
Common situations: Typo or casing mismatch between the registered client ID and the ID passed to set_default_client; calling set_default_client before register_client in the startup sequence; client was deregistered (which also removes routing entries) and then set as default.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Client {client_id} not found
- Order for {} not found to determine position ID
- Client already registered with ID {client_id}
- Venue {venue} already routed to {existing_client_id}, cannot
- default client already registered
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/24754e4acf5381fd.
Report an issue: GitHub.