{"record":{"id":"348ed7cdd42b23ea","repo":"Pumpkin-MC/Pumpkin","slug":"serialization-error-0","errorCode":null,"errorMessage":"Serialization error: {0}","messagePattern":"Serialization error: (.+?)","errorType":"error_code","errorClass":"WorldInfoError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-world/src/world_info/mod.rs","lineNumber":373,"sourceCode":"    pub const fn set_pos(&mut self, x: i32, z: i32) {\n        self.spawn_x = x;\n        self.spawn_z = z;\n    }\n}\n\n#[derive(Error, Debug)]\npub enum WorldInfoError {\n    #[error(\"Io error: {0}\")]\n    IoError(std::io::ErrorKind),\n    #[error(\"Info not found!\")]\n    InfoNotFound,\n    #[error(\"Deserialization error: {0}\")]\n    DeserializationError(String),\n    #[error(\n        \"No world seed found: neither level.dat nor data/minecraft/world_gen_settings.dat contains one\"\n    )]\n    MissingWorldSeed,\n    #[error(\"Serialization error: {0}\")]\n    SerializationError(String),\n    #[error(\"Unsupported world data version: {0}\")]\n    UnsupportedDataVersion(i32),\n    #[error(\"Unsupported world level version: {0}\")]\n    UnsupportedLevelVersion(i32),\n}\n\nimpl From<std::io::Error> for WorldInfoError {\n    fn from(value: std::io::Error) -> Self {\n        match value.kind() {\n            std::io::ErrorKind::NotFound => Self::InfoNotFound,\n            value => Self::IoError(value),\n        }\n    }\n}\n","sourceCodeStart":355,"sourceCodeEnd":389,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-world/src/world_info/mod.rs#L355-L389","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the detail string to identify which field failed to serialize and correct its value in LevelData.","Ensure DataVersion and version fields are set to supported values before saving (see check_data_version/check_level_version ranges).","If LevelData was built programmatically, construct it via the reader or defaults so every field matches the expected NBT schema.","Keep a backup of level.dat so a failed save can be rolled back and retried after the fix."],"exampleFix":"// before: saving LevelData with default/invalid DataVersion\nlet mut data = LevelData::default();\nwriter.write_world_info(&path, &data)?;\n// after: set required version fields first\ndata.data_version = MAXIMUM_SUPPORTED_WORLD_DATA_VERSION;\ndata.version = MAXIMUM_SUPPORTED_LEVEL_VERSION;\nwriter.write_world_info(&path, &data)?;","handlingStrategy":"try-catch","validationCode":"fn level_data_serializable(data: &LevelData) -> Result<(), String> {\n    // ensure version fields present and representable before save\n    if data.data_version == 0 || data.version == 0 {\n        return Err(\"LevelData missing DataVersion/version\".into());\n    }\n    Ok(())\n}","typeGuard":"fn save_ready(data: &LevelData) -> bool {\n    data.data_version >= MINIMUM_SUPPORTED_WORLD_DATA_VERSION\n        && data.data_version <= MAXIMUM_SUPPORTED_WORLD_DATA_VERSION\n        && data.version >= MINIMUM_SUPPORTED_LEVEL_VERSION\n        && data.version <= MAXIMUM_SUPPORTED_LEVEL_VERSION\n}","tryCatchPattern":"match writer.write_world_info(&path, &level) {\n    Err(WorldInfoError::SerializationError(msg)) => {\n        error!(\"save failed: {msg}; level.dat left untouched — fix and retry\");\n    }\n    other => { other?; }\n}","preventionTips":["Build LevelData via the reader or defaults, not from ad-hoc structs","Keep DataVersion/version within supported ranges before saving","Back up level.dat before custom save operations","Test saves in a staging copy of the world first"],"tags":["serialization","nbt","world-info","save"],"backgroundTag":"json-marshal-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"}