Pumpkin-MC/Pumpkin · error · ChunkReadingError

Failed to parse chunk from bytes

Error message

Failed to parse chunk from bytes: {0}

What it means

ChunkReadingError variant fired when the decompressed chunk bytes cannot be deserialized into a Chunk, wrapping ChunkParsingError — valid compression but invalid or incompatible chunk data (corrupt or wrong format version).

Solutions

  1. Restore the chunk from backup or regenerate it
  2. Check the world format version matches the server's parser
  3. Log the parse error with chunk coordinates

Example fix

// before
let chunk = reader.read_chunk(pos)?;
// after
match reader.read_chunk(pos) {
    Ok(c) => Ok(c),
    Err(ChunkReadingError::ParsingError(p)) => { log::error!("bad chunk data: {p}"); generate_chunk(pos) }
    Err(e) => Err(e),
};
Defensive patterns

Strategy: try-catch

Type guard

fn is_parse_failure(e: &ChunkReadingError) -> Option<&ChunkParsingError> {
    if let ChunkReadingError::ParsingError(p) = e { Some(p) } else { None }
}

Try / catch

match reader.read_chunk(pos) {
    Err(ChunkReadingError::ParsingError(p)) => { log::error!("bad chunk: {p}"); regenerate(pos) }
    other => other?,
}

Prevention

When it happens

Trigger: Decompressing a chunk payload whose NBT structure is malformed, from an incompatible Minecraft data version, or produced by a tool that wrote non-standard chunk data.

Common situations: Downgrading a world to an older Minecraft version, region files modified by editors, modded worlds read by vanilla-format parsers.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09). Data as JSON: /api/errors/d342d2a638b8346f. Report an issue: GitHub.

Appendix: source

Thrown at crates/pumpkin-world/src/chunk/mod.rs:40

// TODO
pub const CHUNK_WIDTH: usize = BlockPalette::SIZE;
pub const CHUNK_AREA: usize = CHUNK_WIDTH * CHUNK_WIDTH;
pub const BIOME_VOLUME: usize = BiomePalette::VOLUME;
pub const SUBCHUNK_VOLUME: usize = CHUNK_AREA * CHUNK_WIDTH;

#[derive(Error, Debug)]
pub enum ChunkReadingError {
    #[error("Io error: {0}")]
    IoError(std::io::Error),
    #[error("Invalid header")]
    InvalidHeader,
    #[error("Region is invalid")]
    RegionIsInvalid,
    #[error("Compression error {0}")]
    Compression(CompressionError),
    #[error("Tried to read chunk which does not exist")]
    ChunkNotExist,
    #[error("Failed to parse chunk from bytes: {0}")]
    ParsingError(ChunkParsingError),
}

#[derive(Error, Debug)]
pub enum ChunkWritingError {
    #[error("Io error: {0}")]
    IoError(std::io::Error),
    #[error("Compression error {0}")]
    Compression(CompressionError),
    #[error("Chunk serializing error: {0}")]
    ChunkSerializingError(String),
}

#[derive(Error, Debug)]
pub enum CompressionError {
    #[error("Compression scheme not recognised")]
    UnknownCompression,
    #[error("Error while working with zlib compression: {0}")]

View on GitHub (pinned to 8d4639e25a)