{"record":{"id":"a735fc292b9779eb","repo":"nautechsystems/nautilus_trader","slug":"asks-length-mismatch-expected-depth10-len-was","errorCode":null,"errorMessage":"Asks length mismatch: expected {DEPTH10_LEN}, was {}","messagePattern":"Asks length mismatch: expected (.+?), was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/websocket/parse.rs","lineNumber":335,"sourceCode":"        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,\n        ask_counts,\n        RecordFlag::F_SNAPSHOT as u8,\n        0, // Not applicable for BitMEX L2 books\n        ts_event,\n        ts_init,\n    ))","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/websocket/parse.rs#L317-L353","documentation":"The mirror case for asks: BitMEX `orderBook10` messages must supply exactly DEPTH10_LEN (25) ask levels, and the adapter enforces this when converting the ask `Vec<BookOrder>` into a fixed-size array. Failing that conversion raises this error with the actual ask count. The fixed-width depth model downstream requires exactly 25 levels per side.","triggerScenarios":"`parse_book10_msg` at crates/adapters/bitmex/src/websocket/parse.rs:335 gets an `orderBook10` message whose `asks` array length differs from 25 — short books on illiquid symbols, malformed payloads, or wrong message type routed to this parser.","commonSituations":"New or thinly traded symbols with shallow ask books; hand-written test fixtures with fewer than 25 asks; upstream payload changes from BitMEX; message-routing bugs sending partial depth into the book10 path.","solutions":["Capture the raw message and check the actual ask count; handle shallow books by padding or by using an incremental L2 book path.","Confirm only true `orderBook10` snapshots reach `parse_book10_msg`.","Fix test fixtures to carry exactly 25 ask entries.","Add a pre-validation step that rejects or normalizes depth arrays before `try_into`."],"exampleFix":"// before\nlet fixture_asks = vec![ask1, ask2]; // only 2 levels\n// after\nassert_eq!(fixture_asks.len(), DEPTH10_LEN);\nlet fixture_asks = pad_levels(fixture_asks, DEPTH10_LEN);","handlingStrategy":"validation","validationCode":"if asks.len() != DEPTH10_LEN {\n    return Err(anyhow::anyhow!(\"asks must have exactly {DEPTH10_LEN} levels, got {}\", asks.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(\"Asks length mismatch\") => { log::debug!(\"skipping malformed book10: {e}\"); }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate both bids and asks counts immediately after deserialization.","Keep fixtures at exactly 25 levels per side.","Watch for BitMEX payload changes in integration tests."],"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"}