{"record":{"id":"c1412b05231db6c0","repo":"nautechsystems/nautilus_trader","slug":"failed-to-query-order","errorCode":null,"errorMessage":"Failed to query order {}: {}","messagePattern":"Failed to query order (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/http/client.rs","lineNumber":3169,"sourceCode":"        let order = &response.result.list[0];\n        let ts_init = self.generate_ts_init();\n\n        log::debug!(\n            \"Query order response: symbol={}, order_id={}, order_link_id={}\",\n            order.symbol.as_str(),\n            order.order_id.as_str(),\n            order.order_link_id.as_str()\n        );\n\n        let instrument = self\n            .instrument_from_cache(&instrument_id.symbol)\n            .map_err(|e| {\n                log::error!(\n                    \"Instrument cache miss for symbol '{}': {}\",\n                    instrument_id.symbol.as_str(),\n                    e\n                );\n                anyhow::anyhow!(\n                    \"Failed to query order {}: {}\",\n                    client_order_id\n                        .as_ref()\n                        .map(|id| id.to_string())\n                        .or_else(|| venue_order_id.as_ref().map(|id| id.to_string()))\n                        .unwrap_or_else(|| \"unknown\".to_string()),\n                    e\n                )\n            })?;\n\n        log::debug!(\"Retrieved instrument from cache: id={}\", instrument.id());\n\n        let report =\n            parse_order_status_report(order, &instrument, account_id, ts_init).map_err(|e| {\n                log::error!(\n                    \"Failed to parse order status report for {}: {}\",\n                    order.order_link_id.as_str(),\n                    e","sourceCodeStart":3151,"sourceCodeEnd":3187,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/http/client.rs#L3151-L3187","documentation":"BybitHttpClient's order-query path first resolves the instrument from its local cache; if that lookup fails (the cache-miss error is logged at error level), the wrapper converts it into 'Failed to query order {}: {}' where the first {} is the client_order_id or venue_order_id (or 'unknown' if neither was provided) and the second is the underlying cause. The query cannot proceed without instrument metadata to build the Bybit symbol/category parameters.","triggerScenarios":"Calling query_order/order_status for an order whose instrument_id symbol is not in the instruments cache (instruments never loaded or filtered out), or calling with neither client_order_id nor venue_order_id so the identifier is 'unknown'.","commonSituations":"Reconciliation or order-status polling after a node restart with an instrument provider that excludes the traded symbol; querying orders for instruments added after startup; passing None for both order identifiers.","solutions":["Load instruments for the relevant product type before querying orders so the symbol resolves from cache","Always pass client_order_id or venue_order_id when querying order status","Include the traded symbol in the instrument provider filter config","Restart/reload instruments if the order's instrument was listed after client initialization"],"exampleFix":"// before\nlet status = client.query_order(None, None, instrument_id).await?; // no ids, maybe no instrument\n// after\nclient.load_instruments_all(product_types).await?;\nlet status = client.query_order(Some(client_order_id), Some(venue_order_id), instrument_id).await?;","handlingStrategy":"validation","validationCode":"if client.get_instrument(&instrument_id.symbol.inner()).is_none() {\n    client.load_instruments_all(product_types).await?;\n}\nassert!(client_order_id.is_some() || venue_order_id.is_some(), \"need an order id\");","typeGuard":null,"tryCatchPattern":"match client.query_order(client_order_id, venue_order_id, instrument_id).await {\n    Ok(status) => status,\n    Err(e) if e.to_string().contains(\"Failed to query order\") => {\n        client.load_instruments_all(product_types).await?;\n        client.query_order(client_order_id, venue_order_id, instrument_id).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always pass an order identifier to query calls","Load instruments before any order operations","Keep instrument filters covering all traded symbols across restarts"],"tags":["rust","bybit","orders","cache"],"backgroundTag":"entity-not-found","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"}