{"record":{"id":"3dab62dda7cbc3ca","repo":"nautechsystems/nautilus_trader","slug":"failed-to-build-algo-order-params-e","errorCode":null,"errorMessage":"Failed to build algo order params: {e}","messagePattern":"Failed to build algo order params: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":6666,"sourceCode":"\n        let ts_init = self.generate_ts_init();\n        let mut reports = Vec::new();\n        let mut seen: AHashMap<(String, String), usize> = AHashMap::new();\n\n        if has_specific_lookup {\n            let mut params_builder = GetAlgoOrderParamsBuilder::default();\n\n            if let Some(algo_id) = algo_id {\n                params_builder.algo_id(algo_id);\n            }\n\n            if let Some(client_order_id) = algo_client_order_id {\n                params_builder.algo_cl_ord_id(client_order_id.as_str().to_string());\n            }\n\n            let params = params_builder\n                .build()\n                .map_err(|e| anyhow::anyhow!(format!(\"Failed to build algo order params: {e}\")))?;\n            let mut orders = match self.inner.get_algo_order(params).await {\n                Ok(orders) => orders,\n                Err(e) if e.is_order_not_found() => {\n                    return Ok(AlgoOrderReportSweep {\n                        reports,\n                        complete,\n                        ambiguous_triggered_child_ids,\n                    });\n                }\n                Err(e) => return Err(e.into()),\n            };\n\n            if let Some(state) = state {\n                orders.retain(|order| order.state == state);\n            }\n\n            complete &= self\n                .collect_algo_reports(","sourceCodeStart":6648,"sourceCodeEnd":6684,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L6648-L6684","documentation":"When fetching algo order reports, the adapter assembles OKX request params with a typed builder; a failed build() is wrapped as 'Failed to build algo order params: {e}'. This happens during algo order report sweeps (pending/history) before any HTTP request is made.","triggerScenarios":"Builder validation failure, e.g. both algo_id and algo_client_order_id set when OKX requires exactly one, or missing mandatory fields for the chosen ord_type.","commonSituations":"Setting both algo_cl_ord_id and algo_id; empty ID strings; API surface change in the builder requiring a new mandatory field.","solutions":["Read the inner builder error for the exact violated rule","Provide exactly one of algo_id or algo_client_order_id","Validate ID strings are non-empty before building"],"exampleFix":"// before\nbuilder.algo_id(algo_id).algo_cl_ord_id(cl_id);\n// after\nbuilder.algo_id(algo_id); // only one identifier","handlingStrategy":"validation","validationCode":"if algo_id.is_some() && algo_client_order_id.is_some() {\n    return Err(\"Set only one of algo_id or algo_client_order_id\".into());\n}","typeGuard":null,"tryCatchPattern":"match client.algo_order_reports(...).await {\n    Err(e) if e.to_string().contains(\"Failed to build algo order params\") => {\n        // adjust builder inputs per wrapped cause and retry\n    }\n    other => other?,\n}","preventionTips":["Set exactly one algo identifier per query","Avoid empty strings; use Option instead","Track builder API changes when upgrading the adapter"],"tags":["okx","algo-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"}