{"record":{"id":"f3665d427208fc78","repo":"Pumpkin-MC/Pumpkin","slug":"nbt-error-0","errorCode":null,"errorMessage":"NBT error: {0}","messagePattern":"NBT error: (.+?)","errorType":"error_code","errorClass":"PlayerDataError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-world/src/data/player_data.rs","lineNumber":23,"sourceCode":"use tracing::{debug, error};\nuse uuid::Uuid;\n\n/// Manages the storage and retrieval of player data from disk and memory cache.\n///\n/// This struct provides functions to load and save player data to/from NBT files,\n/// with a memory cache to handle player disconnections temporarily.\npub struct PlayerDataStorage {\n    /// Path to the directory where player data is stored\n    data_path: PathBuf,\n    /// Whether player data saving is enabled\n    save_enabled: bool,\n}\n\n#[derive(Debug, thiserror::Error)]\npub enum PlayerDataError {\n    #[error(\"IO error: {0}\")]\n    Io(#[from] io::Error),\n    #[error(\"NBT error: {0}\")]\n    Nbt(String),\n}\n\nimpl PlayerDataStorage {\n    /// Creates a new `PlayerDataStorage` with the specified data path and cache expiration time.\n    pub fn new(data_path: impl Into<PathBuf>, enabled: bool) -> Self {\n        let path = data_path.into();\n        if !path.exists()\n            && let Err(e) = create_dir_all(&path)\n        {\n            error!(\n                \"Failed to create player data directory at {}: {e}\",\n                path.display()\n            );\n        }\n\n        Self {\n            data_path: path,","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-world/src/data/player_data.rs#L5-L41","documentation":"Variant `Nbt` of `PlayerDataError` in pumpkin-world, carrying a `String` description. The library throws it when player data NBT parsing or writing fails — the stored `.dat` file is not valid NBT or contains unexpected fields when reading player state.","triggerScenarios":"Deserializing a player's `<uuid>.dat` file whose NBT structure is invalid, truncated, or written by an incompatible version.","commonSituations":"Corrupted playerdata from a server crash, playerdata copied between servers with different data versions, manually edited .dat files.","solutions":["Read the String payload for the specific NBT failure and inspect the .dat file","Restore the player's .dat from backup or delete it to reset the player's data","Verify the world's data version matches the running server"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"matches!(err, PlayerDataError::Nbt(_))","tryCatchPattern":"match storage.load_player_data(uuid) {\n    Err(PlayerDataError::Nbt(msg)) => { warn!(\"corrupt playerdata for {uuid}: {msg}; resetting\"); storage.reset(uuid)?; }\n    other => other?,\n}","preventionTips":["Keep periodic backups of the playerdata directory","Do not copy .dat files between servers of different data versions","Never hand-edit player .dat files without validating NBT afterwards"],"tags":["nbt","player-data","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"}