{"record":{"id":"ad8335e9e8b7c0af","repo":"nautechsystems/nautilus_trader","slug":"active-lighter-order-cloid-conflicts-with-venue","errorCode":null,"errorMessage":"active Lighter order {cloid} conflicts with venue order ID {venue_order_id}","messagePattern":"active Lighter order (.+?) conflicts with venue order ID (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":1351,"sourceCode":"                    && existing.matches_venue_order_id(venue_order_id),\n                \"retired Lighter order {cloid} conflicts with reconciliation binding\",\n            );\n            return Ok(());\n        }\n\n        let identity = OrderIdentity::restored(order, client_order_index, venue_order_id);\n\n        if terminal {\n            anyhow::ensure!(\n                self.retired_orders\n                    .cloid_for_venue(client_order_index, venue_order_id)\n                    .is_none(),\n                \"retired Lighter binding conflicts at client_order_index {client_order_index} and venue order ID {venue_order_id}\",\n            );\n            self.retired_orders.insert(cloid, identity);\n        } else {\n            if let Some(existing) = self.venue_id_map.get(&cloid) {\n                anyhow::ensure!(\n                    *existing.value() == venue_order_id,\n                    \"active Lighter order {cloid} conflicts with venue order ID {venue_order_id}\",\n                );\n            }\n\n            match self.cloid_map.entry(client_order_index) {\n                dashmap::mapref::entry::Entry::Vacant(entry) => {\n                    self.venue_id_map.insert(cloid, venue_order_id);\n                    self.order_identities.insert(cloid, identity);\n                    entry.insert(cloid);\n                    if order.is_triggered() == Some(true) {\n                        self.mark_triggered_emitted(cloid);\n                    }\n                }\n                dashmap::mapref::entry::Entry::Occupied(_) => {\n                    anyhow::bail!(\n                        \"active Lighter binding conflicts at client_order_index {client_order_index}\",\n                    );","sourceCodeStart":1333,"sourceCodeEnd":1369,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L1333-L1369","documentation":"For a new non-terminal bind, the venue_id_map must not already associate the cloid with a different venue order ID. ensure! fails when the cached venue ID for this cloid differs from the event's venue_order_id, preventing one client order from being silently rebound to another venue order.","triggerScenarios":"An active-order event remaps an existing cloid to a new venue_order_id (wrong event routing, cloid reuse, or corrupted venue_id_map).","commonSituations":"Reusing client_order_ids across sessions without clearing state, misrouted dispatch after reconnect, venue data anomalies.","solutions":["Reset the adapter's order state (venue_id_map/cloid_map) and re-reconcile","Use unique client order IDs per session","Trace where the cloid was first bound and why the venue ID changed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if let Some(existing) = state.venue_id_for(&cloid) {\n    if *existing != vid {\n        tracing::error!(\"cloid {cloid} remapped {} -> {vid}; rebuilding\", existing);\n        reset_order_state().await?;\n    }\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = bind_reconciliation(order, idx, vid, terminal).await {\n    if e.to_string().contains(\"conflicts with venue order ID\") {\n        reset_order_state().await?;\n        full_reconcile_from_venue().await?;\n        return Ok(());\n    }\n    return Err(e);\n}","preventionTips":["Never reuse client_order_ids across adapter sessions","Verify event routing after reconnect so events land on the right orders","Treat any venue-ID remap of a live cloid as a red alert — investigate, don't overwrite"],"tags":["rust","websocket","reconciliation","conflict"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}