{"record":{"id":"730e6792e69c9c10","repo":"Pumpkin-MC/Pumpkin","slug":"failed-to-decode-varlong-value-too-large","errorCode":null,"errorMessage":"Failed to decode varlong - value too large","messagePattern":"Failed to decode varlong - value too large","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-nbt/src/lib.rs","lineNumber":104,"sourceCode":"    #[error(\"Serde error: {0}\")]\n    SerdeError(String),\n    /// The requested Rust type has no NBT representation.\n    #[error(\"NBT doesn't support this type: {0}\")]\n    UnsupportedType(String),\n    /// The underlying reader or writer returned an I/O error.\n    #[error(\"NBT reading was cut short: {0}\")]\n    Incomplete(io::Error),\n    /// A list or array declared a negative element count.\n    #[error(\"Negative list length: {0}\")]\n    NegativeLength(i32),\n    /// A string, list, or array exceeded the supported length.\n    #[error(\"Length too large: {0}\")]\n    LargeLength(usize),\n    /// A Bedrock variable-length integer exceeded its maximum encoded size.\n    #[error(\"Failed to decode varint - value too large\")]\n    VarIntTooLarge,\n    /// A Bedrock variable-length long exceeded its maximum encoded size.\n    #[error(\"Failed to decode varlong - value too large\")]\n    VarLongTooLarge,\n    /// NBT nesting depth exceeded the maximum allowed limit.\n    #[error(\"NBT depth exceeded maximum allowed limit\")]\n    MaxDepthExceeded,\n    /// A list tag specified an invalid element tag type.\n    #[error(\"Invalid element tag type for list: {0}\")]\n    InvalidListTag(u8),\n}\n\n/// A complete NBT document containing a named root compound.\n#[derive(Clone, Debug, Default, PartialEq)]\npub struct Nbt {\n    /// Name stored alongside the root compound.\n    pub name: String,\n    /// Root compound containing the document's tags.\n    pub root_tag: NbtCompound,\n}\n","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-nbt/src/lib.rs#L86-L122","documentation":"NBT decode guard for Bedrock variable-length longs: a VarLong continued past its maximum encoded size (10 bytes) and could not be decoded. Fires on the same kind of input as VarIntTooLarge but for 64-bit fields — a corrupted or misaligned varlong in the Bedrock NBT stream.","triggerScenarios":"Reading Bedrock NBT where a varlong has its high continuation bit set past the 10-byte maximum.","commonSituations":"Corrupted Bedrock world data, buffer misalignment when reading embedded NBT, or mixing varint/varlong decoders across NBT variants.","solutions":["Reject the containing packet or NBT blob","Limit varlong reads to the maximum encoded length","Log the oversized varlong at debug level"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"fn varlong_len_ok(bytes: &[u8]) -> bool { bytes.iter().take(10).position(|b| b & 0x80 == 0).is_some() }","typeGuard":null,"tryCatchPattern":"if let Err(Error::VarLongTooLarge) = result { mark_source_corrupt(); }","preventionTips":["Never hand-roll varlong decoding; use the library's reader","Validate offsets before each field read","Test against both Java and Bedrock NBT samples"],"tags":["nbt","varlong","bedrock","deserialization"],"backgroundTag":"value-out-of-range","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}