Pumpkin-MC/Pumpkin · error · Error
Length too large
Error message
Length too large: {0} What it means
This is Error::LargeLength from pumpkin-nbt's Error enum. It is thrown when a string, list, or array declared in the NBT payload exceeds the supported length, preventing huge allocations from hostile or corrupt data.
Solutions
- Validate the length field against your expected payload size before deserializing
- Verify you are using the correct NBT variant (Java vs Bedrock) for the data source
- Truncate/reject the input and log the offending connection or file
Example fix
// before
let nbt = Nbt::from_reader(&mut cursor).unwrap();
// after
match Nbt::from_reader(&mut cursor) {
Ok(nbt) => nbt,
Err(Error::LargeLength(len)) => { log::warn!("NBT length too large: {}", len); return; }
Err(e) => return Err(e.into()),
} Defensive patterns
Strategy: validation
Validate before calling
fn length_ok(len: i32, max: usize) -> bool { len >= 0 && (len as usize) <= max } Try / catch
match result { Err(Error::LargeLength(n)) => reject_input(n), Err(e) => propagate(e), Ok(v) => use(v) } Prevention
- Sanity-check declared lengths against remaining buffer size before deserializing
- Cap incoming payload sizes at the network/framing layer
- Use the correct NBT variant for the data source
When it happens
Trigger: Deserializing an NBT payload whose length prefix (string length, list len, or array size) exceeds the library's maximum supported size.
Common situations: Malformed packets from untrusted clients, corrupted world/level.dat data, or reading Bedrock NBT buffers with a mismatched byte-offset.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Serde error
- Failed to decode varint - value too large
- Failed to decode varlong - value too large
- Invalid element tag type for list
- unexpected EOF
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/a36e89e62c989314.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-nbt/src/lib.rs:98
#[error("Failed to Cesu 8 Decode")]
Cesu8DecodingError,
/// A string could not be decoded as UTF-8.
#[error("Failed to UTF-8 Decode")]
Utf8DecodingError,
/// Serde reported an invalid value or serializer state.
#[error("Serde error: {0}")]
SerdeError(String),
/// The requested Rust type has no NBT representation.
#[error("NBT doesn't support this type: {0}")]
UnsupportedType(String),
/// The underlying reader or writer returned an I/O error.
#[error("NBT reading was cut short: {0}")]
Incomplete(io::Error),
/// A list or array declared a negative element count.
#[error("Negative list length: {0}")]
NegativeLength(i32),
/// A string, list, or array exceeded the supported length.
#[error("Length too large: {0}")]
LargeLength(usize),
/// A Bedrock variable-length integer exceeded its maximum encoded size.
#[error("Failed to decode varint - value too large")]
VarIntTooLarge,
/// A Bedrock variable-length long exceeded its maximum encoded size.
#[error("Failed to decode varlong - value too large")]
VarLongTooLarge,
/// NBT nesting depth exceeded the maximum allowed limit.
#[error("NBT depth exceeded maximum allowed limit")]
MaxDepthExceeded,
/// A list tag specified an invalid element tag type.
#[error("Invalid element tag type for list: {0}")]
InvalidListTag(u8),
}
/// A complete NBT document containing a named root compound.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Nbt {View on GitHub (pinned to 8d4639e25a)