{"record":{"id":"d28eebff4e9a026a","repo":"nautechsystems/nautilus_trader","slug":"exactly-one-of-client-order-id-or-venue-order-id-i","errorCode":null,"errorMessage":"Exactly one of client_order_id or venue_order_id is required for an order detail request","messagePattern":"Exactly one of client_order_id or venue_order_id is required for an order detail request","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":4375,"sourceCode":"    async fn request_order_status_report_by_identifier(\n        &self,\n        account_id: AccountId,\n        instrument_id: InstrumentId,\n        client_order_id: Option<ClientOrderId>,\n        venue_order_id: Option<VenueOrderId>,\n    ) -> anyhow::Result<Option<OrderStatusReport>> {\n        let instrument = self.instrument_from_cache(instrument_id.symbol.inner())?;\n        let mut params_builder = GetOrderParamsBuilder::default();\n        params_builder.inst_id(instrument_id.symbol.inner().to_string());\n\n        match (client_order_id, venue_order_id) {\n            (Some(client_order_id), None) => {\n                params_builder.cl_ord_id(client_order_id.as_str().to_string());\n            }\n            (None, Some(venue_order_id)) => {\n                params_builder.ord_id(venue_order_id.as_str().to_string());\n            }\n            _ => anyhow::bail!(\n                \"Exactly one of client_order_id or venue_order_id is required for an order detail request\"\n            ),\n        }\n\n        let params = params_builder\n            .build()\n            .map_err(|e| anyhow::anyhow!(\"Failed to build order detail params: {e}\"))?;\n        let orders = match self.inner.get_order(params).await {\n            Ok(orders) => orders,\n            Err(e) if e.is_order_not_found() => return Ok(None),\n            Err(e) => return Err(e.into()),\n        };\n        let order = match orders.as_slice() {\n            [] => return Ok(None),\n            [order] => order,\n            _ => anyhow::bail!(\n                \"Order detail returned {} records for one identifier\",\n                orders.len(),","sourceCodeStart":4357,"sourceCodeEnd":4393,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L4357-L4393","documentation":"request_order_detail requires exactly one order identifier: the match on (client_order_id, venue_order_id) accepts (Some, None) or (None, Some); any other combination — both None or both Some — bails. OKX's order-detail endpoint takes either clOrdId or ordId, not both, and the adapter maps exactly one.","triggerScenarios":"Calling the OKX HTTP client's order-detail method with both identifiers None, or both Some (ambiguous request).","commonSituations":"Report generation code that opportunistically fills both IDs (venue rejects the call); fallback logic that neither ID resolved; refactored callers passing both 'to be safe'.","solutions":["Pass exactly one of client_order_id or venue_order_id — prefer venue_order_id (ordId) if known","Clear one identifier before the call when both are present","Ensure upstream identifier resolution succeeds before invoking the detail request"],"exampleFix":"// before\nclient.request_order_detail(instrument_id, Some(coid), Some(oid)).await?;\n// after\nclient.request_order_detail(instrument_id, None, Some(oid)).await?;","handlingStrategy":"validation","validationCode":"match (client_order_id, venue_order_id) {\n    (Some(_), None) | (None, Some(_)) => {}\n    _ => return Err(anyhow::anyhow!(\"pass exactly one order identifier\")),\n}","typeGuard":"fn single_identifier(c: Option<ClientOrderId>, v: Option<VenueOrderId>) -> bool {\n    matches!((c.is_some(), v.is_some()), (true, false) | (false, true))\n}","tryCatchPattern":"match client.request_order_detail(instrument_id, coid, void).await {\n    Ok(Some(report)) => { /* use */ }\n    Ok(None) => { /* order not found */ }\n    Err(e) => log::error!(\"order detail failed: {e}\"),\n}","preventionTips":["Pass exactly one identifier; prefer venue_order_id when known","Never pass both identifiers 'for safety' — the API rejects it","Ensure fallback logic always resolves at least one ID before calling"],"tags":["okx","orders","validation","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","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"}