{"record":{"id":"9bcf0536055c7282","repo":"nautechsystems/nautilus_trader","slug":"sbe-execution-report-block-length-too-short-expec","errorCode":null,"errorMessage":"SBE execution report block length too short: expected at least {min_block_len}, was {block_length}","messagePattern":"SBE execution report block length too short: expected at least (.+?), was (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/websocket/trading/decode_sbe.rs","lineNumber":92,"sourceCode":"    let version = buf.get_u16_at(6);\n\n    if template_id != execution_report_event_codec::SBE_TEMPLATE_ID {\n        anyhow::bail!(\n            \"Wrong template ID: expected {}, received {template_id}\",\n            execution_report_event_codec::SBE_TEMPLATE_ID\n        );\n    }\n\n    if schema_id != crate::spot::sbe::spot::SBE_SCHEMA_ID {\n        anyhow::bail!(\n            \"Wrong schema ID: expected {}, received {schema_id}\",\n            crate::spot::sbe::spot::SBE_SCHEMA_ID\n        );\n    }\n\n    let min_block_len = execution_report_min_block_length(version);\n    if usize::from(block_length) < min_block_len {\n        anyhow::bail!(\n            \"SBE execution report block length too short: expected at least {min_block_len}, was {block_length}\"\n        );\n    }\n\n    let min_len = HEADER_LEN + usize::from(block_length);\n    if data.len() < min_len {\n        anyhow::bail!(\n            \"Buffer too short for fixed block: expected {min_len}, was {}\",\n            data.len()\n        );\n    }\n\n    let mut field_offset = min_len;\n    for field in EXECUTION_REPORT_VAR_DATA_FIELDS {\n        let Some(length) = data.get(field_offset) else {\n            anyhow::bail!(\n                \"Buffer too short for {field} length: expected {}, was {}\",\n                field_offset + 1,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/websocket/trading/decode_sbe.rs#L74-L110","documentation":"The SBE ExecutionReportEvent fixed block length declared in the frame header (bytes 0-1) is smaller than the minimum required for the message's schema version, so mandatory fields would be missing. The decoder computes the version-specific minimum via execution_report_min_block_length(version) and bails rather than reading uninitialized/absent fields.","triggerScenarios":"Calling decode_execution_report with a frame whose header block_length is below the version minimum (268 for v0, 281 for v1, 282 for v3) — e.g. a truncated/corrupted frame, a hand-crafted buffer with a wrong block_length, or a frame produced by an incompatible encoder.","commonSituations":"Corrupted WebSocket frames or incomplete reassembly; test fixtures edited so the header block_length no longer matches the encoded body; a producer built against an older schema sending short blocks.","solutions":["Re-encode the payload with the execution_report_event_codec so the header block_length matches the body","Check the frame transport for truncation before it reaches the decoder","Update fixtures' header block_length to the correct value for their schema version","Verify the adapter's codec version matches Binance's current SBE schema"],"exampleFix":"// before\nlet mut frame = header_bytes;\nframe.extend_from_slice(&body[..100]); // block_length says 282\n// after\nanyhow::ensure!(body.len() >= block_length as usize, \"fixture body shorter than declared block_length\");\nframe.extend_from_slice(&body);","handlingStrategy":"validation","validationCode":"pub fn has_valid_block_length(data: &[u8]) -> bool {\n    if data.len() < 8 { return false; }\n    let block_length = u16::from_be_bytes([data[0], data[1]]) as usize;\n    let version = u16::from_be_bytes([data[6], data[7]]);\n    block_length >= EXECUTION_REPORT_BLOCK_LENGTH_V0 // conservative floor\n        && data.len() >= 8 + block_length\n}","typeGuard":null,"tryCatchPattern":"match decode_execution_report(&frame) {\n    Ok(r) => handle(r),\n    Err(e) if e.to_string().contains(\"block length too short\") => {\n        metrics::increment(\"sbe.short_block\");\n    }\n    Err(e) => log::warn!(\"SBE decode failed: {e}\"),\n}","preventionTips":["Always encode frames with the provided codec rather than hand-building headers","Check transport integrity (no truncation) before decoding","Keep fixture header block_length consistent with the encoded body","Know the per-version minimum block lengths when supporting old schema versions"],"tags":["sbe","binance","buffer","truncated"],"backgroundTag":"invalid-argument-format","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"}