{"record":{"id":"6c00a2d7847661ca","repo":"Pumpkin-MC/Pumpkin","slug":"failed-to-decompress-nbt-0","errorCode":null,"errorMessage":"Failed to decompress NBT: {0}","messagePattern":"Failed to decompress NBT: (.+?)","errorType":"error_code","errorClass":"TemplateError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-world/src/generation/structure/template/structure_template.rs","lineNumber":19,"sourceCode":"//! Structure template loading, transformation, and saving (1:1 matching Minecraft vanilla `StructureTemplate`).\n//!\n//! This module handles parsing vanilla Minecraft structure template files (`.nbt`)\n//! into a runtime representation with palettes, entities, block info, and transformations.\n\nuse std::io::Cursor;\n\nuse pumpkin_data::{Mirror, Rotation};\nuse pumpkin_nbt::{compound::NbtCompound, nbt_compress::read_gzip_compound_tag, tag::NbtTag};\nuse pumpkin_util::math::{block_box::BlockBox, vector3::Vector3};\nuse thiserror::Error;\n\nuse super::processor::StructureProcessor;\nuse crate::generation::structure::structures::jigsaw::JigsawJointType;\n\n/// Errors that can occur when loading or saving a structure template.\n#[derive(Debug, Error)]\npub enum TemplateError {\n    #[error(\"Failed to decompress NBT: {0}\")]\n    NbtError(#[from] pumpkin_nbt::Error),\n\n    #[error(\"Missing required field: {0}\")]\n    MissingField(&'static str),\n\n    #[error(\"Invalid field type for {0}\")]\n    InvalidFieldType(&'static str),\n\n    #[error(\"Invalid palette index: {0}\")]\n    InvalidPaletteIndex(u32),\n}\n\n/// Settings used when placing, transforming, or querying a [`StructureTemplate`].\n#[derive(Clone, Debug)]\npub struct StructurePlaceSettings {\n    pub mirror: Mirror,\n    pub rotation: Rotation,\n    pub rotation_pivot: Vector3<i32>,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-world/src/generation/structure/template/structure_template.rs#L1-L37","documentation":"Variant `NbtError` of `TemplateError` in pumpkin-world's structure template loader, auto-converted from `pumpkin_nbt::Error`. It is thrown when loading (decompressing/parsing) a structure template NBT fails — typically a `.nbt` structure file read during jigsaw/structure placement.","triggerScenarios":"Loading a structure template file whose NBT payload cannot be decompressed or parsed (bad gzip/NBT header, truncated file).","commonSituations":"Structure files exported by third-party tools in the wrong format, corrupted resource-pack/datapack structure files, text files saved as `.nbt` without compression.","solutions":["Verify the structure file is valid compressed NBT (test with an NBT viewer)","Re-export the structure from the same Minecraft version the server targets","Replace the corrupted template file in the world/datapack"],"exampleFix":"// before: assuming file is valid NBT\nlet nbt = pumpkin_nbt::from_reader(&mut file)?;\n// after: guard with an existence/format check first\nif file.metadata()?.len() == 0 { return Err(TemplateError::NbtError(...)); }\nlet nbt = pumpkin_nbt::from_reader(&mut file)?;","handlingStrategy":"validation","validationCode":"let meta = std::fs::metadata(path)?;\nif meta.len() == 0 { return Err(\"empty structure template\".into()); }\nlet magic = std::fs::read(path)?.get(..2).map(|b| b.as_ref());\nif magic != Some(&[0x1f, 0x8b]) { return Err(\"not gzip-compressed NBT\".into()); }","typeGuard":"fn looks_like_gzip_nbt(bytes: &[u8]) -> bool { bytes.starts_with(&[0x1f, 0x8b]) }","tryCatchPattern":"match StructureTemplate::load(path) {\n    Err(TemplateError::NbtError(e)) => error!(\"invalid structure NBT at {path}: {e}\"),\n    other => other?,\n}","preventionTips":["Only ship structure files exported by a matching Minecraft version","Validate datapack structure files with an NBT viewer before deploying","Check gzip magic bytes (0x1f 0x8b) before parsing"],"tags":["nbt","structure-templates","deserialization"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}