{"record":{"id":"275d5d75ace64062","repo":"nautechsystems/nautilus_trader","slug":"venue-venue-already-routed-to-existing-client-i","errorCode":null,"errorMessage":"Venue {venue} already routed to {existing_client_id}, cannot re-route to {client_id}","messagePattern":"Venue (.+?) already routed to (.+?), cannot re-route to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/data/src/engine/mod.rs","lineNumber":549,"sourceCode":"    /// Sets routing for a specific venue to a given client ID.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the client ID is not registered, or the venue is already routed to a\n    /// different client.\n    pub fn register_venue_routing(\n        &mut self,\n        client_id: ClientId,\n        venue: Venue,\n    ) -> anyhow::Result<()> {\n        if !self.clients.contains_key(&client_id) {\n            anyhow::bail!(\"No client registered with ID {client_id}\");\n        }\n\n        if let Some(existing_client_id) = self.routing_map.get(&venue)\n            && *existing_client_id != client_id\n        {\n            anyhow::bail!(\n                \"Venue {venue} already routed to {existing_client_id}, \\\n                 cannot re-route to {client_id}\"\n            );\n        }\n\n        self.routing_map.insert(venue, client_id);\n        log::debug!(\"Set client {client_id} routing for {venue}\");\n        Ok(())\n    }\n\n    /// Starts all registered data clients and re-arms bar aggregator timers.\n    pub fn start(&mut self) {\n        for client in self.get_clients_mut() {\n            if let Err(e) = client.start() {\n                log::error!(\"{e}\");\n            }\n        }\n","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/data/src/engine/mod.rs#L531-L567","documentation":"A Venue can be routed to only one client. register_venue_routing refuses to overwrite an existing routing entry when the new ClientId differs from the one already mapped to that Venue, bailing with this message. Re-registering the same client for the same venue is idempotent and allowed.","triggerScenarios":"Calling register_venue_routing(client_id, venue) when routing_map already contains venue mapped to a different client_id — e.g. two registrations for the same venue from different config sections or different adapters claiming the same venue.","commonSituations":"Duplicate venue routing entries in a TOML/JSON config; two adapters both supporting the same venue both being routed; re-running registration code after the routing table was already populated.","solutions":["Remove the conflicting routing registration so only one client maps to the venue.","If re-routing is intended, clear/replace the existing routing map entry via the engine's API instead of double-registering.","Deduplicate config so each venue appears in the routing section only once."],"exampleFix":"// before\nengine.register_venue_routing(ClientId::from(\"Bybit\"), venue)?; // venue already routed to Binance\n// after\n// keep exactly one routing entry per venue\nengine.register_venue_routing(ClientId::from(\"Binance\"), venue)?;","handlingStrategy":"validation","validationCode":"// Rust\n// detect duplicate venue routing before registering\nif let Some(existing) = planned_routing.get(&venue) {\n    if existing != &client_id {\n        return Err(format!(\"venue {venue} routed twice: {existing} and {client_id}\"));\n    }\n}\nplanned_routing.insert(venue, client_id);\nengine.register_venue_routing(client_id, venue)?;","typeGuard":null,"tryCatchPattern":"// Rust\nif let Err(e) = engine.register_venue_routing(client_id, venue) {\n    if e.to_string().contains(\"already routed\") {\n        log::warn!(\"ignoring duplicate venue routing: {e}\"); // treat re-route conflict as config bug\n    } else {\n        return Err(e);\n    }\n}","preventionTips":["Keep exactly one routing entry per venue in configuration.","Validate the routing section of config at load time for duplicate venue keys.","Make registration idempotent: skip re-registering an identical venue→client pair."],"tags":["rust","data-engine","routing","conflict"],"backgroundTag":"invalid-state-transition","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}