{"record":{"id":"e4c5049f2e21c874","repo":"nautechsystems/nautilus_trader","slug":"generate-order-status-report-requires-client-order","errorCode":null,"errorMessage":"generate_order_status_report requires client_order_id or venue_order_id","messagePattern":"generate_order_status_report requires client_order_id or venue_order_id","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/execution.rs","lineNumber":1994,"sourceCode":"        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            })\n        };\n        let cached_venue_order_id = order_state.and_then(|state| state.venue_order_id);\n        let regular_venue_order_id = order_state.and_then(|state| {\n            if OKX_CONDITIONAL_ORDER_TYPES.contains(&state.order_type) {","sourceCodeStart":1976,"sourceCodeEnd":2012,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/execution.rs#L1976-L2012","documentation":"After checking instrument_id, generate_order_status_report requires at least one order identifier: a client_order_id or a venue_order_id. Without either, OKX cannot be asked for a specific order, so the adapter bails immediately. It defines the minimum identifying information for a single-order status lookup.","triggerScenarios":"Invoking generate_order_status_report (including via assert_bootstrap_reports) with a GenerateOrderStatusReport where both client_order_id and venue_order_id are None.","commonSituations":"Reconciliation/bootstrap flows that construct report requests from partial data; deserialization paths that drop order IDs; hand-built commands in tests or custom report pipelines.","solutions":["Populate either client_order_id or venue_order_id on the command before calling","Ensure the upstream report-generation code forwards the identifiers it already holds","If no identifier is available, this order cannot be queried — log and skip instead of calling"],"exampleFix":"// before\nlet cmd = GenerateOrderStatusReport { instrument_id: Some(id), client_order_id: None, venue_order_id: None, .. };\n// after\nlet cmd = GenerateOrderStatusReport { instrument_id: Some(id), client_order_id: Some(client_order_id), venue_order_id: None, .. };","handlingStrategy":"validation","validationCode":"if cmd.instrument_id.is_none() || (cmd.client_order_id.is_none() && cmd.venue_order_id.is_none()) {\n    return Err(anyhow::anyhow!(\"order status report needs instrument_id plus one order identifier\"));\n}","typeGuard":"fn is_queryable(cmd: &GenerateOrderStatusReport) -> bool {\n    cmd.instrument_id.is_some()\n        && (cmd.client_order_id.is_some() || cmd.venue_order_id.is_some())\n}","tryCatchPattern":"match exec.generate_order_status_report(&cmd).await {\n    Ok(r) => { /* handle */ }\n    Err(e) => log::warn!(\"order status report skipped: {e}\"),\n}","preventionTips":["Never build report commands without at least one order identifier","Propagate client_order_id/venue_order_id through reconciliation pipelines instead of dropping Option fields","Validate commands at construction time, not at request time"],"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-14T05:17:10.506Z"}