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

  1. Register the client with register_client before calling set_default_client.
  2. Verify the ClientId matches exactly the one used at registration (ClientIds are compared exactly).
  3. Reorder startup code so client registration precedes default assignment.
  4. 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

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


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/24754e4acf5381fd. Report an issue: GitHub.