{"record":{"id":"46008a18fb5ffd97","repo":"Pumpkin-MC/Pumpkin","slug":"invalid-header","errorCode":null,"errorMessage":"Invalid header","messagePattern":"Invalid header","errorType":"error_code","errorClass":"ChunkReadingError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-world/src/chunk/mod.rs","lineNumber":32,"sourceCode":"use std::sync::atomic::AtomicBool;\nuse std::sync::atomic::AtomicU64;\nuse thiserror::Error;\n\npub mod format;\npub mod io;\npub mod palette;\n\n// TODO\npub const CHUNK_WIDTH: usize = BlockPalette::SIZE;\npub const CHUNK_AREA: usize = CHUNK_WIDTH * CHUNK_WIDTH;\npub const BIOME_VOLUME: usize = BiomePalette::VOLUME;\npub const SUBCHUNK_VOLUME: usize = CHUNK_AREA * CHUNK_WIDTH;\n\n#[derive(Error, Debug)]\npub enum ChunkReadingError {\n    #[error(\"Io error: {0}\")]\n    IoError(std::io::Error),\n    #[error(\"Invalid header\")]\n    InvalidHeader,\n    #[error(\"Region is invalid\")]\n    RegionIsInvalid,\n    #[error(\"Compression error {0}\")]\n    Compression(CompressionError),\n    #[error(\"Tried to read chunk which does not exist\")]\n    ChunkNotExist,\n    #[error(\"Failed to parse chunk from bytes: {0}\")]\n    ParsingError(ChunkParsingError),\n}\n\n#[derive(Error, Debug)]\npub enum ChunkWritingError {\n    #[error(\"Io error: {0}\")]\n    IoError(std::io::Error),\n    #[error(\"Compression error {0}\")]\n    Compression(CompressionError),\n    #[error(\"Chunk serializing error: {0}\")]","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-world/src/chunk/mod.rs#L14-L50","documentation":"`ChunkReadingError::InvalidHeader` is raised when a chunk/region file's header does not match the expected format (a magic/structure check failed on read). It indicates the file is not a valid chunk/region file of the expected version.","triggerScenarios":"Reading a chunk file whose header bytes are wrong — empty file with only zeros, truncated header, or a file written by an incompatible world format version.","commonSituations":"Pointing the server at a world generated by a different version or another engine; partially written files after a crash; empty placeholder region files; user renamed/moved world files incorrectly.","solutions":["Verify the world format version matches what this server version expects","Regenerate or restore the region file from a backup","Check for empty/corrupt files (file size, hexdump the header bytes)","Re-run world conversion/migration tooling for format upgrades"],"exampleFix":"// before\nlet chunk = ChunkReader::read(path)?; // InvalidHeader on bad format\n// after\nmatch ChunkReader::read(path) {\n    Ok(c) => c,\n    Err(ChunkReadingError::InvalidHeader) => {\n        log::warn!(\"bad chunk header at {path:?}; regenerating\");\n        regenerate_chunk();\n    }\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"fallback","validationCode":"// sanity-check the file before parsing\nlet meta = std::fs::metadata(&path)?;\nif meta.len() < HEADER_SIZE { return Err(WorldError::BadRegionFile(path)); }","typeGuard":null,"tryCatchPattern":"match chunk::read(&path) {\n    Ok(c) => c,\n    Err(ChunkReadingError::InvalidHeader) => {\n        log::warn!(\"invalid header in {path:?}; regenerating chunk\");\n        regenerate_chunk();\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Never mix world files across game/server format versions","Run migration tooling before loading worlds from older versions","Detect and quarantine zero-length or truncated region files after crashes"],"tags":["world","chunk","corrupt-data","format"],"backgroundTag":"invalid-argument-format","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"}