{"record":{"id":"957b5f7ee2fdd0db","repo":"nautechsystems/nautilus_trader","slug":"failed-to-build-order-detail-params-e","errorCode":null,"errorMessage":"Failed to build order detail params: {e}","messagePattern":"Failed to build order detail params: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":4382,"sourceCode":"        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(),\n            ),\n        };\n\n        if order.inst_id.as_str() != instrument_id.symbol.inner() {\n            anyhow::bail!(\n                \"Order detail instrument mismatch for {instrument_id}: returned {}\",\n                order.inst_id,","sourceCodeStart":4364,"sourceCodeEnd":4400,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L4364-L4400","documentation":"The order detail request builds its OKX params with a typed builder (GetOrderDetailParamsBuilder / GetOrderHistoryParamsBuilder); if the builder's required fields are missing or invalid, build() returns an error which is wrapped as 'Failed to build order detail params: {e}'.","triggerScenarios":"Calling order detail lookup where exactly one of client_order_id or venue_order_id was set but the builder still fails validation (e.g. both set, neither set, or malformed ID format per builder rules).","commonSituations":"Passing both client and venue order IDs; passing an empty/blank order ID string; upstream refactor changed builder required fields.","solutions":["Pass exactly one of client_order_id or venue_order_id","Log/inspect the inner builder error message appended to this error for the specific missing field","Validate the ID is non-empty and correctly formatted before calling"],"exampleFix":"// before\nlet params = builder.cl_ord_id(cl_id).ord_id(venue_id).build()?;\n// after\nlet params = builder.ord_id(venue_id).build()?; // set only one ID","handlingStrategy":"validation","validationCode":"let exactly_one = client_order_id.is_some() ^ venue_order_id.is_some();\nif !exactly_one { return Err(\"Set exactly one of client_order_id or venue_order_id\".into()); }","typeGuard":null,"tryCatchPattern":"match client.order_detail(...).await {\n    Err(e) if e.to_string().starts_with(\"Failed to build order detail params\") => {\n        // fix builder inputs per the wrapped cause\n    }\n    other => other?,\n}","preventionTips":["Enforce XOR of client/venue order ID at the type or call-site level","Never pass empty ID strings; use Option::None instead","Surface and read the inner builder error, it names the violated rule"],"tags":["okx","orders","builder","validation"],"backgroundTag":"schema-validation-failed","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"}