{"record":{"id":"1b2aa9ef95553fb1","repo":"nautechsystems/nautilus_trader","slug":"bids-length-mismatch-expected-depth10-len-was","errorCode":null,"errorMessage":"Bids length mismatch: expected {DEPTH10_LEN}, was {}","messagePattern":"Bids length mismatch: expected (.+?), was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/websocket/parse.rs","lineNumber":329,"sourceCode":"\n        bids.push(bid_order);\n        bid_counts[i] = 1;\n    }\n\n    for (i, level) in msg.asks.iter().enumerate() {\n        let ask_order = BookOrder::new(\n            OrderSide::Sell,\n            Price::new(level[0], price_precision),\n            parse_fractional_quantity(level[1], instrument),\n            0,\n        );\n\n        asks.push(ask_order);\n        ask_counts[i] = 1;\n    }\n\n    let bids: [BookOrder; DEPTH10_LEN] = bids.try_into().map_err(|v: Vec<BookOrder>| {\n        anyhow::anyhow!(\n            \"Bids length mismatch: expected {DEPTH10_LEN}, was {}\",\n            v.len()\n        )\n    })?;\n    let asks: [BookOrder; DEPTH10_LEN] = asks.try_into().map_err(|v: Vec<BookOrder>| {\n        anyhow::anyhow!(\n            \"Asks length mismatch: expected {DEPTH10_LEN}, was {}\",\n            v.len()\n        )\n    })?;\n\n    let ts_event = UnixNanos::from(msg.timestamp);\n\n    Ok(OrderBookDepth10::new(\n        instrument_id,\n        bids,\n        asks,\n        bid_counts,","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/websocket/parse.rs#L311-L347","documentation":"BitMEX `orderBook10` depth messages must contain exactly DEPTH10_LEN (25) bid levels; the adapter converts the parsed bid vector into a fixed-size `[BookOrder; DEPTH10_LEN]` array. `Vec::try_into` fails when the count differs, and this error reports the actual length received. The fixed array is required by the downstream order book data model.","triggerScenarios":"`parse_book10_msg` at crates/adapters/bitmex/src/websocket/parse.rs:329 receives an `orderBook10` message whose `bids` array has fewer or more than 25 entries — e.g. a thin book on a new/illiquid symbol, or a malformed/truncated message.","commonSituations":"Illiquid or new symbols where BitMEX sends fewer than 25 levels; test fixtures with short bid arrays; BitMEX changing depth payload semantics; feeding an `orderBookL2` style message into the book10 parser.","solutions":["Log the offending message and confirm the symbol/book actually has fewer than 25 levels; pad the top-of-book by replicating or treat as partial depth if supported.","Ensure the message being parsed is genuinely an `orderBook10` snapshot and not another depth message type.","Update test fixtures to include exactly 25 bid entries.","If BitMEX changed the payload, adjust the parser to validate/normalize to DEPTH10_LEN before conversion."],"exampleFix":"// before\n// fixture with only 3 bid levels fed to parse_book10_msg\nlet bids = vec![level1, level2, level3];\n// after\nlet bids = pad_to_depth10(bids); // ensure exactly DEPTH10_LEN entries before parsing\n// or filter: if bids.len() != DEPTH10_LEN { skip/update incremental book instead }","handlingStrategy":"validation","validationCode":"if bids.len() != DEPTH10_LEN {\n    return Err(anyhow::anyhow!(\"bids must have exactly {DEPTH10_LEN} levels, got {}\", bids.len()));\n}","typeGuard":"fn is_full_depth(v: &[BookOrder]) -> bool { v.len() == DEPTH10_LEN }","tryCatchPattern":"match parse_book10_msg(&msg) {\n    Ok(book) => book,\n    Err(e) if e.to_string().contains(\"length mismatch\") => { log::debug!(\"shallow/invalid book10 skipped: {e}\"); fallback_to_l2(msg); }\n    Err(e) => return Err(e),\n}","preventionTips":["Route only true orderBook10 snapshots to parse_book10_msg.","Pad or reject depth arrays to DEPTH10_LEN before conversion.","Expect shallow books on new/illiquid symbols and use the incremental L2 path."],"tags":["websocket","orderbook","bitmex","length-mismatch"],"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-14T05:17:10.506Z"}