Pumpkin-MC/Pumpkin · error · WorldInfoError

Serialization error

Error message

Serialization error: {0}

What it means

WorldInfoError::SerializationError(String) is returned when writing world info back to disk fails while converting LevelData into NBT or serializing it. The String carries the detail of what could not be serialized. This surfaces during WorldInfoWriter::write_world_info (world_info/mod.rs:26), i.e. on world save.

Solutions

  1. Read the detail string to identify which field failed to serialize and correct its value in LevelData.
  2. Ensure DataVersion and version fields are set to supported values before saving (see check_data_version/check_level_version ranges).
  3. If LevelData was built programmatically, construct it via the reader or defaults so every field matches the expected NBT schema.
  4. Keep a backup of level.dat so a failed save can be rolled back and retried after the fix.

Example fix

// before: saving LevelData with default/invalid DataVersion
let mut data = LevelData::default();
writer.write_world_info(&path, &data)?;
// after: set required version fields first
data.data_version = MAXIMUM_SUPPORTED_WORLD_DATA_VERSION;
data.version = MAXIMUM_SUPPORTED_LEVEL_VERSION;
writer.write_world_info(&path, &data)?;
Defensive patterns

Strategy: try-catch

Validate before calling

fn level_data_serializable(data: &LevelData) -> Result<(), String> {
    // ensure version fields present and representable before save
    if data.data_version == 0 || data.version == 0 {
        return Err("LevelData missing DataVersion/version".into());
    }
    Ok(())
}

Type guard

fn save_ready(data: &LevelData) -> bool {
    data.data_version >= MINIMUM_SUPPORTED_WORLD_DATA_VERSION
        && data.data_version <= MAXIMUM_SUPPORTED_WORLD_DATA_VERSION
        && data.version >= MINIMUM_SUPPORTED_LEVEL_VERSION
        && data.version <= MAXIMUM_SUPPORTED_LEVEL_VERSION
}

Try / catch

match writer.write_world_info(&path, &level) {
    Err(WorldInfoError::SerializationError(msg)) => {
        error!("save failed: {msg}; level.dat left untouched — fix and retry");
    }
    other => { other?; }
}

Prevention

When it happens

Trigger: WorldInfoWriter::write_world_info fails to convert a LevelData field into an NBT tag (e.g. an out-of-range or unrepresentable value) or the NBT serializer errors while producing the level.dat payload; the write path then reports this variant instead of saving.

Common situations: A LevelData populated from non-vanilla sources with values that violate the NBT schema; custom code constructing LevelData programmatically and calling save; version-skew where a new field cannot be represented for the chosen DataVersion.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


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

Appendix: source

Thrown at crates/pumpkin-world/src/world_info/mod.rs:373

    pub const fn set_pos(&mut self, x: i32, z: i32) {
        self.spawn_x = x;
        self.spawn_z = z;
    }
}

#[derive(Error, Debug)]
pub enum WorldInfoError {
    #[error("Io error: {0}")]
    IoError(std::io::ErrorKind),
    #[error("Info not found!")]
    InfoNotFound,
    #[error("Deserialization error: {0}")]
    DeserializationError(String),
    #[error(
        "No world seed found: neither level.dat nor data/minecraft/world_gen_settings.dat contains one"
    )]
    MissingWorldSeed,
    #[error("Serialization error: {0}")]
    SerializationError(String),
    #[error("Unsupported world data version: {0}")]
    UnsupportedDataVersion(i32),
    #[error("Unsupported world level version: {0}")]
    UnsupportedLevelVersion(i32),
}

impl From<std::io::Error> for WorldInfoError {
    fn from(value: std::io::Error) -> Self {
        match value.kind() {
            std::io::ErrorKind::NotFound => Self::InfoNotFound,
            value => Self::IoError(value),
        }
    }
}

View on GitHub (pinned to 8d4639e25a)