{"record":{"id":"31f382b373369c75","repo":"nautechsystems/nautilus_trader","slug":"order-missing-ord-status-and-cannot-infer-order-i","errorCode":null,"errorMessage":"Order missing ord_status and cannot infer (order_id={}, client_order_id={:?}, leaves_qty={:?}, cum_qty={:?}, working_indicator={:?}, order_json={})","messagePattern":"Order missing ord_status and cannot infer \\(order_id=(.+?), client_order_id=(.+?), leaves_qty=(.+?), cum_qty=(.+?), working_indicator=(.+?), order_json=(.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/http/parse.rs","lineNumber":887,"sourceCode":"                    \"Inferred Canceled from missing ordStatus (leaves_qty=0, cum_qty<=0): order_id={:?}, client_order_id={:?}, cum_qty={:?}\",\n                    order.order_id,\n                    order.cl_ord_id,\n                    order.cum_qty,\n                );\n                OrderStatus::Canceled\n            }\n            // BitMEX cancel responses may omit all quantity fields but include working_indicator\n            (None, None, Some(false)) => {\n                log::debug!(\n                    \"Inferred Canceled from missing ordStatus with working_indicator=false: order_id={:?}, client_order_id={:?}\",\n                    order.order_id,\n                    order.cl_ord_id,\n                );\n                OrderStatus::Canceled\n            }\n            _ => {\n                let order_json = serde_json::to_string(order)?;\n                anyhow::bail!(\n                    \"Order missing ord_status and cannot infer (order_id={}, client_order_id={:?}, leaves_qty={:?}, cum_qty={:?}, working_indicator={:?}, order_json={})\",\n                    order.order_id,\n                    order.cl_ord_id,\n                    order.leaves_qty,\n                    order.cum_qty,\n                    order.working_indicator,\n                    order_json\n                );\n            }\n        }\n    };\n\n    // Try to get order_qty, or reconstruct from cum_qty + leaves_qty\n    let (quantity, filled_qty) = if let Some(qty) = order.order_qty {\n        let quantity = parse_signed_contracts_quantity(qty, instrument);\n        let filled_qty = parse_signed_contracts_quantity(order.cum_qty.unwrap_or(0), instrument);\n        (quantity, filled_qty)\n    } else if let (Some(cum), Some(leaves)) = (order.cum_qty, order.leaves_qty) {","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/http/parse.rs#L869-L905","documentation":"Raised by parse_order_status_report when a BitmexOrder has no ordStatus and the adapter's inference fallbacks (via leaves_qty, cum_qty, and working_indicator, handled in preceding match arms) also cannot determine the order's state. Without a resolvable status the adapter cannot build a valid OrderStatusReport, so it fails with full diagnostic context including the raw order JSON.","triggerScenarios":"Receiving an order payload from a submit/cancel/modify/query response with ordStatus=null AND none of the inference conditions matching (e.g. no leaves/cum quantity hints and no working indicator). Occurs with partial or malformed BitMEX responses.","commonSituations":"BitMEX websocket/REST payload edge cases (orders created without status during transient states); API version drift changing which fields are populated; custom or mocked endpoints returning minimal order objects.","solutions":["Inspect the order_json embedded in the error to see exactly which fields BitMEX returned","Re-query the order via query_order or request_order_status_report to fetch a payload with ordStatus populated","Check for BitMEX API updates that may have made ordStatus optional or renamed fields","If reproducible, file an issue so the inference logic in parse.rs can cover the new payload shape"],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.request_order_status_report(instrument_id, client_order_id, venue_order_id).await {\n    Ok(report) => { /* handle */ }\n    Err(e) if e.to_string().contains(\"Order missing ord_status\") => {\n        // extract order_json from message, re-query after a short delay\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Retry order status fetches after a short backoff — transient payloads often lack ordStatus","Pin the adapter to BitMEX API versions whose order payloads always include ordStatus","If it reproduces, capture order_json from the error and report the payload shape upstream","Keep parse.rs inference logic updated when BitMEX adds new order states"],"tags":["rust","bitmex","order-status","parse-error"],"backgroundTag":"unexpected-api-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"}