nautechsystems/nautilus_trader · error

Cannot handle request: no client found for {:?} {:?}

Error message

Cannot handle request: no client found for {:?} {:?}

What it means

`execute_defi_request` on the DataEngine looks up the registered data client matching the request's client_id and venue, then forwards the DeFi request to it. This error means no registered client matches, so the engine cannot route the request anywhere. It is a routing/registration failure, not a network failure.

Source

Thrown at crates/data/src/defi/engine.rs:219

    /// # Errors
    ///
    /// Returns an error if no client is found for the given client ID or venue,
    /// or if the client fails to process the request.
    pub fn execute_defi_request(&mut self, req: DefiRequestCommand) -> anyhow::Result<()> {
        // Skip requests for external clients
        if let Some(cid) = req.client_id()
            && self.external_clients.contains(cid)
        {
            if self.config.debug {
                log::debug!("Skipping defi data request for external client {cid}: {req:?}");
            }
            return Ok(());
        }

        if let Some(client) = self.get_client(req.client_id(), req.venue()) {
            client.execute_defi_request(req)
        } else {
            anyhow::bail!(
                "Cannot handle request: no client found for {:?} {:?}",
                req.client_id(),
                req.venue()
            );
        }
    }

    /// Processes DeFi-specific data events.
    pub fn process_defi_data(&mut self, data: DefiData) {
        self.increment_data_count();

        match data {
            DefiData::Block(block) => {
                let topic = defi::switchboard::get_defi_blocks_topic(block.chain());
                msgbus::publish_defi_block(topic, &block);
            }
            DefiData::Pool(pool) => {
                if let Err(e) = self.cache.borrow_mut().add_pool(pool.clone()) {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Register the data client for the request's client_id/venue before executing (check the setup path, e.g. setup_pool_updater)
  2. Log/inspect the request's client_id and venue and compare against the engine's registered clients
  3. Fix client_id mismatches (the client_id the client registered with must equal the one on the request)
  4. Ensure client startup completes before any requests are submitted

Example fix

// before
engine.execute(req)?; // req.venue() never registered
// after
if engine.get_client(req.client_id(), req.venue()).is_none() {
    tracing::error!("no client for {:?} {:?}", req.client_id(), req.venue());
    return; // or register the client first
}
engine.execute(req)?;
Defensive patterns

Strategy: try-catch

Validate before calling

// check routability before executing
if engine.get_client(req.client_id(), req.venue()).is_none() {
    tracing::error!("no client registered for {:?} {:?}", req.client_id(), req.venue());
    return; // or register first
}
engine.execute(req)?;

Try / catch

match engine.execute(req) {
    Ok(()) => (),
    Err(e) if e.to_string().starts_with("Cannot handle request") => {
        tracing::error!("client not registered: {e}"); // defer or register client
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `execute`/`execute_defi_request` with a request whose `client_id` was never registered via the client registration path (`setup_pool_updater` registers clients), or whose `venue` does not match the venue the client was registered for.

Common situations: Submitting DeFi requests before client startup/registration completes; a typo or mismatch between the client_id used when registering and the one on the request; requesting a venue the client doesn't support; clients unregistered on disconnect.

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/d90f7beb3c234f2c. Report an issue: GitHub.