{"record":{"id":"6736b65dcf8eae8d","repo":"nautechsystems/nautilus_trader","slug":"failed-to-build-spread-order-detail-params-e","errorCode":null,"errorMessage":"Failed to build spread order detail params: {e}","messagePattern":"Failed to build spread order detail params: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":7056,"sourceCode":"    ) -> anyhow::Result<Option<OrderStatusReport>> {\n        let instrument = self.instrument_from_cache(instrument_id.symbol.inner())?;\n        let mut params_builder = GetSpreadOrderParamsBuilder::default();\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 a spread order detail request\"\n            ),\n        }\n\n        let params = params_builder\n            .build()\n            .map_err(|e| anyhow::anyhow!(\"Failed to build spread order detail params: {e}\"))?;\n        let orders = match self.inner.get_spread_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 Some(order) = orders.into_iter().next() else {\n            return Ok(None);\n        };\n        let ts_init = self.generate_ts_init();\n        let report = parse_spread_order_status_report(\n            &order,\n            account_id,\n            instrument.id(),\n            instrument.price_precision(),\n            instrument.size_precision(),\n            ts_init,\n        )?;\n","sourceCodeStart":7038,"sourceCodeEnd":7074,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L7038-L7074","documentation":"The OKX adapter builds request parameters for a spread order detail lookup via a typed params builder. When `build()` fails (required fields unset or mutually exclusive fields set), the adapter wraps the builder error in this anyhow error. The caller must provide exactly one of client_order_id or venue_order_id.","triggerScenarios":"Calling the spread order detail lookup with neither client_order_id nor venue_order_id set, or failing other builder invariants (e.g. unset required instrument fields), causing `params_builder.build()` to return Err.","commonSituations":"Reconciliation/retry code that looks up an order status but lost the original client_order_id and never set venue_order_id; code passing empty/None IDs after deserializing partial order records.","solutions":["Ensure the request supplies exactly one identifier: a non-empty client_order_id OR venue_order_id before calling the detail lookup.","Log/inspect the inner builder error (`{e}`) to see which specific param invariant failed.","If looking up by exchange ID, fetch venue_order_id from a prior order submission/ack rather than leaving it None."],"exampleFix":"// before\nlet params = SpreadOrderDetailParams::new().build()?; // no id set\n// after\nlet params = SpreadOrderDetailParams::new()\n    .client_order_id(client_order_id)\n    .build()?;","handlingStrategy":"validation","validationCode":"// rust\nif client_order_id.is_none() == venue_order_id.is_none() {\n    return Err(anyhow!(\"provide exactly one of client_order_id or venue_order_id\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always carry the client_order_id from order submission through to status lookups.","Never call spread order detail with an empty/None identifier."],"tags":["okx","params-builder","spread-orders","validation"],"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"}