{"record":{"id":"3a43a2617e5c3fa0","repo":"nautechsystems/nautilus_trader","slug":"order-list-contains-a-duplicate-order-id","errorCode":null,"errorMessage":"order list {} contains a duplicate order ID","messagePattern":"order list (.+?) contains a duplicate order ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/execution.rs","lineNumber":2564,"sourceCode":"    anyhow::ensure!(\n        !response.orders.is_empty() && response.orders.len() == response.order_reports.len(),\n        \"order list {} has {} orders and {} reports\",\n        response.order_list_id,\n        response.orders.len(),\n        response.order_reports.len(),\n    );\n\n    let mut list_orders = AHashMap::with_capacity(response.orders.len());\n    for order in response.orders {\n        anyhow::ensure!(\n            order.symbol == response.symbol,\n            \"order list {} contains order {} for symbol {}, expected {}\",\n            response.order_list_id,\n            order.order_id,\n            order.symbol,\n            response.symbol,\n        );\n        anyhow::ensure!(\n            list_orders.insert(order.order_id, order).is_none(),\n            \"order list {} contains a duplicate order ID\",\n            response.order_list_id,\n        );\n    }\n\n    for report in response.order_reports {\n        anyhow::ensure!(\n            report.order_list_id == Some(response.order_list_id),\n            \"order {} reports order-list ID {:?}, expected {}\",\n            report.order_id,\n            report.order_list_id,\n            response.order_list_id,\n        );\n        let order = list_orders.remove(&report.order_id).with_context(|| {\n            format!(\n                \"order-list report {} is absent from list {}\",\n                report.order_id, response.order_list_id","sourceCodeStart":2546,"sourceCodeEnd":2582,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/execution.rs#L2546-L2582","documentation":"While validating a cancel-open-orders OrderList response, the trader collects child orders into a map keyed by order ID and requires each entry to be unique. This error means the payload contained the same order ID twice within one order list, which the Binance API contract forbids — so the response is malformed or mis-decoded.","triggerScenarios":"Binance cancel-open-orders returns an OrderList response whose orders[] array contains two entries with the identical orderId — arising from a decoding bug, duplicate message assembly, or corrupted SBE data.","commonSituations":"Adapter/SBE schema drift after a Binance protocol update; duplicated frames from a replayed or retried response being merged; corrupted binary payloads through intermediaries.","solutions":["Update the nautilus_binance adapter to the latest version to fix potential SBE decode duplication","Retry the cancel-all request to check if the duplicate payload recurs","Capture and inspect the raw response; if duplication is real, report it to Binance/adapter maintainers","Rule out middleware or proxies that could duplicate response frames"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let ids: AHashSet<i64> = response.orders.iter().map(|o| o.order_id).collect();\nif ids.len() != response.orders.len() {\n    return Err(anyhow!(\"order list {} contains duplicate order IDs\", response.order_list_id));\n}","typeGuard":"fn no_duplicate_order_ids(resp: &BinanceCancelOrderListResponse) -> bool {\n    let ids: AHashSet<i64> = resp.orders.iter().map(|o| o.order_id).collect();\n    ids.len() == resp.orders.len()\n}","tryCatchPattern":"match prepare_cancel_all_orders(...) {\n    Ok(p) => handle(p),\n    Err(e) if e.to_string().contains(\"duplicate order ID\") => log::error!(\"malformed list payload: {e}\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the adapter's SBE decoder current with Binance schema changes","Retry transient failures before escalating; do not replay-merge duplicate responses","Instrument raw payload capture for order-list flows"],"tags":["binance","validation","duplicate-data","order-list"],"backgroundTag":"unexpected-response-shape","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"}