nautechsystems/nautilus_trader · error
SBE execution report block length too short: expected at lea
Error message
SBE execution report block length too short: expected at least {min_block_len}, was {block_length} What it means
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.
Source
Thrown at crates/adapters/binance/src/spot/websocket/trading/decode_sbe.rs:92
let version = buf.get_u16_at(6);
if template_id != execution_report_event_codec::SBE_TEMPLATE_ID {
anyhow::bail!(
"Wrong template ID: expected {}, received {template_id}",
execution_report_event_codec::SBE_TEMPLATE_ID
);
}
if schema_id != crate::spot::sbe::spot::SBE_SCHEMA_ID {
anyhow::bail!(
"Wrong schema ID: expected {}, received {schema_id}",
crate::spot::sbe::spot::SBE_SCHEMA_ID
);
}
let min_block_len = execution_report_min_block_length(version);
if usize::from(block_length) < min_block_len {
anyhow::bail!(
"SBE execution report block length too short: expected at least {min_block_len}, was {block_length}"
);
}
let min_len = HEADER_LEN + usize::from(block_length);
if data.len() < min_len {
anyhow::bail!(
"Buffer too short for fixed block: expected {min_len}, was {}",
data.len()
);
}
let mut field_offset = min_len;
for field in EXECUTION_REPORT_VAR_DATA_FIELDS {
let Some(length) = data.get(field_offset) else {
anyhow::bail!(
"Buffer too short for {field} length: expected {}, was {}",
field_offset + 1,View on GitHub (pinned to 18893faf8b)
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
Example fix
// before let mut frame = header_bytes; frame.extend_from_slice(&body[..100]); // block_length says 282 // after anyhow::ensure!(body.len() >= block_length as usize, "fixture body shorter than declared block_length"); frame.extend_from_slice(&body);
Defensive patterns
Strategy: validation
Validate before calling
pub fn has_valid_block_length(data: &[u8]) -> bool {
if data.len() < 8 { return false; }
let block_length = u16::from_be_bytes([data[0], data[1]]) as usize;
let version = u16::from_be_bytes([data[6], data[7]]);
block_length >= EXECUTION_REPORT_BLOCK_LENGTH_V0 // conservative floor
&& data.len() >= 8 + block_length
} Try / catch
match decode_execution_report(&frame) {
Ok(r) => handle(r),
Err(e) if e.to_string().contains("block length too short") => {
metrics::increment("sbe.short_block");
}
Err(e) => log::warn!("SBE decode failed: {e}"),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Buffer too short for fixed block: expected {min_len}, was {}
- Buffer too short for {field} length: expected {}, was {}
- Buffer too short for {field}: expected {expected_len}, was {
- Symbol '{}' is not trading (status: {})
- Buffer too short for SBE header: expected {HEADER_LEN}, was
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/9bcf0536055c7282.
Report an issue: GitHub.