{"record":{"id":"b82d9f8411e9f165","repo":"nautechsystems/nautilus_trader","slug":"generate-order-status-report-requires-instrument-i","errorCode":null,"errorMessage":"generate_order_status_report requires instrument_id","messagePattern":"generate_order_status_report requires instrument_id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/execution.rs","lineNumber":1990,"sourceCode":"        Ok(())\n    }\n\n    fn reset(&mut self) -> anyhow::Result<()> {\n        self.begin_generation_shutdown();\n        Ok(())\n    }\n\n    fn dispose(&mut self) -> anyhow::Result<()> {\n        self.begin_generation_shutdown();\n        Ok(())\n    }\n\n    async fn generate_order_status_report(\n        &self,\n        cmd: &GenerateOrderStatusReport,\n    ) -> anyhow::Result<Option<OrderStatusReport>> {\n        let Some(instrument_id) = cmd.instrument_id else {\n            anyhow::bail!(\"generate_order_status_report requires instrument_id\");\n        };\n\n        if cmd.client_order_id.is_none() && cmd.venue_order_id.is_none() {\n            anyhow::bail!(\n                \"generate_order_status_report requires client_order_id or venue_order_id\"\n            );\n        }\n\n        let order_state = {\n            let cache = self.core.cache();\n            cmd.client_order_id.and_then(|client_order_id| {\n                cache\n                    .order(&client_order_id)\n                    .map(|order| CachedQueryOrderState {\n                        order_type: order.order_type(),\n                        venue_order_id: order.venue_order_id(),\n                    })\n            })","sourceCodeStart":1972,"sourceCodeEnd":2008,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/execution.rs#L1972-L2008","documentation":"OKXExecutionClient::generate_order_status_report requires the command to carry an instrument_id so it can resolve the OKX instrument (instId) for the order query. If cmd.instrument_id is None, the adapter bails with anyhow before making any request. This is a guard against issuing an OKX order-detail lookup that cannot name an instrument.","triggerScenarios":"Calling generate_order_status_report (directly or via the execution engine's report generation / assert_bootstrap_reports reconciliation) with a GenerateOrderStatusReport whose instrument_id field is None.","commonSituations":"Building a report request from data where the instrument was never parsed (e.g. reconstructing a command from a venue_order_id alone during reconciliation or bootstrap), or wiring the command struct by hand and forgetting to fill instrument_id.","solutions":["Set instrument_id on the GenerateOrderStatusReport before calling generate_order_status_report","If only a venue_order_id is known, resolve the instrument_id first (from cache or order state) and pass it explicitly","When the instrument is genuinely unknown, skip this report or look the order up via a venue-wide order list endpoint instead of the single-order detail path"],"exampleFix":"// before\nlet cmd = GenerateOrderStatusReport { instrument_id: None, client_order_id: Some(coid), .. };\n// after\nlet cmd = GenerateOrderStatusReport { instrument_id: Some(instrument_id), client_order_id: Some(coid), .. };","handlingStrategy":"validation","validationCode":"if cmd.instrument_id.is_none() {\n    return Err(anyhow::anyhow!(\"cannot generate order status report without instrument_id\"));\n}","typeGuard":"fn has_instrument_id(cmd: &GenerateOrderStatusReport) -> bool {\n    cmd.instrument_id.is_some()\n}","tryCatchPattern":"match exec.generate_order_status_report(&cmd).await {\n    Ok(Some(report)) => { /* use report */ }\n    Ok(None) => { /* order not found */ }\n    Err(e) if e.to_string().contains(\"requires instrument_id\") => { /* fix command and retry */ }\n    Err(e) => return Err(e),\n}","preventionTips":["Always populate instrument_id when constructing GenerateOrderStatusReport","Derive instrument_id from the order/event you are reconciling rather than leaving it optional","Add a unit test asserting report commands carry instrument_id"],"tags":["okx","validation","missing-argument","execution"],"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"}