{"record":{"id":"e29479396bd4e176","repo":"nautechsystems/nautilus_trader","slug":"lighter-order-lookup-requires-an-instrument-id-pe","errorCode":null,"errorMessage":"Lighter order lookup requires an instrument_id (per-market REST query)","messagePattern":"Lighter order lookup requires an instrument_id \\(per-market REST query\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":1804,"sourceCode":"/// submission and the venue's first `account_*` ack, while avoiding ambiguous\n/// terminal history where Lighter can reuse client indexes.\n#[expect(\n    clippy::too_many_arguments,\n    reason = \"order lookup threads context to the parser without a wrapper struct\"\n)]\npub(crate) async fn lookup_order_status_report(\n    http_client: &LighterHttpClient,\n    registry: &Arc<MarketRegistry>,\n    credential: &Credential,\n    account_id: AccountId,\n    instrument_id: Option<InstrumentId>,\n    client_order_id: Option<&ClientOrderId>,\n    venue_order_id: Option<&VenueOrderId>,\n    dispatch: &WsDispatchState,\n    clock: &'static AtomicTime,\n) -> anyhow::Result<Option<OrderStatusReport>> {\n    let instrument_id = instrument_id.ok_or_else(|| {\n        anyhow::anyhow!(\"Lighter order lookup requires an instrument_id (per-market REST query)\")\n    })?;\n    let market_index = registry\n        .market_index(&instrument_id)\n        .ok_or_else(|| anyhow::anyhow!(\"no Lighter market_index for instrument {instrument_id}\"))?;\n\n    // Try, in order: explicit voi, cached voi, derived client_order_index.\n    let target_venue_index: Option<i64> = venue_order_id\n        .and_then(|voi| voi.as_str().parse::<i64>().ok())\n        .or_else(|| {\n            client_order_id\n                .and_then(|cloid| dispatch.lookup_venue_order_id(cloid))\n                .and_then(|voi| voi.as_str().parse::<i64>().ok())\n        });\n    let target_client_index: Option<i64> = client_order_id.map(|cloid| {\n        dispatch\n            .client_order_index(cloid)\n            .unwrap_or_else(|| dispatch.derive_client_order_index(cloid))\n    });","sourceCodeStart":1786,"sourceCodeEnd":1822,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L1786-L1822","documentation":"Lighter's REST order-status query is per-market, so the lookup needs a Nautilus instrument_id to derive the market_index. Calling the order-lookup/reconciliation path without an instrument_id is rejected rather than falling back to a venue-wide (nonexistent) query.","triggerScenarios":"Invoking query_order (or reconciliation) with instrument_id=None — e.g. order status requests built from client_order_id or venue_order_id alone.","commonSituations":"Requesting an order status from a generic OrderStatus command that does not carry an instrument_id; reconciliation of orders whose instrument was not recorded.","solutions":["Always supply instrument_id in the order status request (OrdersQuery/OrderStatus with instrument_id set).","If only the venue_order_id is known, look up the order's instrument first, then retry the query.","Skip per-order lookup for requests lacking instrument_id instead of calling this per-market REST path."],"exampleFix":"// before\nclient.query_order(None, Some(&voi), ...)\n// after\nclient.query_order(Some(instrument_id), Some(&voi), ...)","handlingStrategy":"validation","validationCode":"anyhow::ensure!(instrument_id.is_some(), \"order lookup requires instrument_id\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include instrument_id in OrderStatus/OrdersQuery commands","Resolve the order's instrument before per-market REST lookups"],"tags":["rest","lookup","missing-argument"],"backgroundTag":"missing-required-argument","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"}