{"record":{"id":"9035def17474fda2","repo":"nautechsystems/nautilus_trader","slug":"no-instrument-cached-for-clob-pair-id-clob-pair-i","errorCode":null,"errorMessage":"No instrument cached for clob_pair_id {clob_pair_id}","messagePattern":"No instrument cached for clob_pair_id (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/websocket/parse.rs","lineNumber":94,"sourceCode":"/// - HTTP parser fails.\npub fn parse_ws_order_report(\n    ws_order: &DydxWsOrderSubaccountMessageContents,\n    instrument_cache: &InstrumentCache,\n    order_contexts: &DashMap<u32, OrderContext>,\n    encoder: &ClientOrderIdEncoder,\n    account_id: AccountId,\n    ts_init: UnixNanos,\n) -> anyhow::Result<OrderStatusReport> {\n    let clob_pair_id: u32 = ws_order.clob_pair_id.parse().context(format!(\n        \"Failed to parse clob_pair_id '{}'\",\n        ws_order.clob_pair_id\n    ))?;\n\n    let instrument = instrument_cache\n        .get_by_clob_id(clob_pair_id)\n        .ok_or_else(|| {\n            instrument_cache.log_missing_clob_pair_id(clob_pair_id);\n            anyhow::anyhow!(\"No instrument cached for clob_pair_id {clob_pair_id}\")\n        })?;\n\n    let http_order = convert_ws_order_to_http(ws_order)?;\n    let mut report = parse_order_status_report(&http_order, &instrument, account_id, ts_init)?;\n\n    let dydx_client_id = ws_order.client_id.parse::<u32>().ok();\n    let dydx_client_metadata = ws_order\n        .client_metadata\n        .as_ref()\n        .and_then(|s| s.parse::<u32>().ok())\n        .unwrap_or(crate::grpc::DEFAULT_RUST_CLIENT_METADATA);\n\n    log::debug!(\n        \"[WS_ORDER_RECV] dYdX client_id='{}' meta={:#x} (parsed u32={:?}) | status={:?} | clob_pair={} | side={:?} | size={} | filled={}\",\n        ws_order.client_id,\n        dydx_client_metadata,\n        dydx_client_id,\n        ws_order.status,","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/websocket/parse.rs#L76-L112","documentation":"parse_ws_order_report maps a dYdX WebSocket order update to an OrderStatusReport, which requires the corresponding instrument. The instrument cache is looked up by clob_pair_id; if no instrument was cached for that ID the update cannot be converted and this error is thrown (after logging the missing ID). This typically means instrument loading or the websocket subscriptions are out of sync.","triggerScenarios":"Receiving a WebSocket order status update whose clob_pair_id is not present in the instrument cache — e.g. an order on a market never loaded via the HTTP instruments endpoint, or the cache was cleared/not populated before the WS stream started.","commonSituations":"Starting the websocket stream before instruments finish loading; trading a newly listed market while cached instruments are stale; subscribing to channels for markets outside the configured instruments.","solutions":["Ensure the HTTP instrument load/populate of the instrument cache completes before spawning the WS stream handler","Subscribe only to markets whose instruments are cached, or load the missing instrument for that clob_pair_id","Check the logged 'missing clob_pair_id' to identify which market needs to be added to the cache","Restart/reconnect after refreshing instruments so the cache is current"],"exampleFix":"// before\nspawn_ws_stream_handler(stream) // instruments not yet loaded\n// after\nload_all_instruments(&mut instrument_cache).await?;\nspawn_ws_stream_handler(stream);","handlingStrategy":"validation","validationCode":"if instrument_cache.get_by_clob_id(clob_pair_id).is_none() {\n    return Err(anyhow!(\"instrument for clob_pair_id {clob_pair_id} not loaded; load instruments before streaming\"));\n}\n// proceed to parse_ws_order_report","typeGuard":"fn is_clob_cached(cache: &InstrumentCache, id: u64) -> bool {\n    cache.get_by_clob_id(id).is_some()\n}","tryCatchPattern":"match parse_ws_order_report(...) {\n    Err(e) if e.to_string().contains(\"No instrument cached for clob_pair_id\") => {\n        warn!(\"skipping order update for uncached market\");\n    }\n    Err(e) => return Err(e),\n    Ok(r) => publish(r),\n}","preventionTips":["Always finish HTTP instrument loading before starting WS stream handlers","Subscribe only to markets present in the instrument cache","Refresh the cache when new markets are listed"],"tags":["rust","dydx","websocket","cache"],"backgroundTag":"record-not-found","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"}