{"record":{"id":"b242c9fedc1518dc","repo":"Pumpkin-MC/Pumpkin","slug":"nbt-doesn-t-support-this-type-0","errorCode":null,"errorMessage":"NBT doesn't support this type: {0}","messagePattern":"NBT doesn't support this type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-nbt/src/lib.rs","lineNumber":89,"sourceCode":"#[derive(Error, Debug)]\npub enum Error {\n    /// The root tag was not a compound tag and contains the reported tag ID.\n    #[error(\"The root tag of the NBT file is not a compound tag. Received tag id: {0}\")]\n    NoRootCompound(u8),\n    /// A tag ID not defined by the NBT format was encountered.\n    #[error(\"Encountered an unknown NBT tag id: {0}.\")]\n    UnknownTagId(u8),\n    /// A Java CESU-8 string could not be decoded.\n    #[error(\"Failed to Cesu 8 Decode\")]\n    Cesu8DecodingError,\n    /// A string could not be decoded as UTF-8.\n    #[error(\"Failed to UTF-8 Decode\")]\n    Utf8DecodingError,\n    /// Serde reported an invalid value or serializer state.\n    #[error(\"Serde error: {0}\")]\n    SerdeError(String),\n    /// The requested Rust type has no NBT representation.\n    #[error(\"NBT doesn't support this type: {0}\")]\n    UnsupportedType(String),\n    /// The underlying reader or writer returned an I/O error.\n    #[error(\"NBT reading was cut short: {0}\")]\n    Incomplete(io::Error),\n    /// A list or array declared a negative element count.\n    #[error(\"Negative list length: {0}\")]\n    NegativeLength(i32),\n    /// A string, list, or array exceeded the supported length.\n    #[error(\"Length too large: {0}\")]\n    LargeLength(usize),\n    /// A Bedrock variable-length integer exceeded its maximum encoded size.\n    #[error(\"Failed to decode varint - value too large\")]\n    VarIntTooLarge,\n    /// A Bedrock variable-length long exceeded its maximum encoded size.\n    #[error(\"Failed to decode varlong - value too large\")]\n    VarLongTooLarge,\n    /// NBT nesting depth exceeded the maximum allowed limit.\n    #[error(\"NBT depth exceeded maximum allowed limit\")]","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-nbt/src/lib.rs#L71-L107","documentation":"Error::UnsupportedType(String) is raised when a Rust type being serialized to (or deserialized from) NBT has no NBT representation. NBT only supports a fixed set of types (numeric primitives, strings, byte/int/long arrays, lists, compounds, booleans-as-bytes); anything else (units, maps with non-string keys, newtype oddities) cannot be mapped. The string names the offending type.","triggerScenarios":"Serializing a struct containing u128/char/unit/f32-vs-f64-conflicting types, a HashMap with non-string keys, or a tuple NBT cannot express, through the serde NBT serializer; calling to_nbt on a type whose Serialize impl emits types outside the NBT model.","commonSituations":"Using serde defaults (e.g., u128 fields from other crates) in config structs saved as NBT; map keys that are enums or integers; deeply generic code that unknowingly passes unsupported types through.","solutions":["Read the type name in the error and replace it with an NBT-representable type (e.g., i64 instead of u128).","Convert non-string map keys to strings or restructure as a list of compounds with key/value tags.","Implement a custom Serialize/Deserialize for the type that maps it onto compounds/lists.","For newtype/unit-like wrappers, flatten them or store as their inner value."],"exampleFix":"// before\nstruct Data { id: u128 }\n// after\nstruct Data { id: i64 }","handlingStrategy":"type-guard","validationCode":"// Rust: restrict your data model to NBT-representable types\nfn nbt_repr<'a, T: Serialize>(v: &'a T) {} // compile-time check via a dedicated trait if available","typeGuard":null,"tryCatchPattern":"match value.to_nbt() {\n    Err(pumpkin_nbt::Error::UnsupportedType(t)) => eprintln!(\"type {t} cannot be stored in NBT\"),\n    Err(e) => return Err(e.into()),\n    Ok(tag) => tag,\n}","preventionTips":["Avoid u128, char, unit, and non-string-keyed maps in NBT-bound structs","Write custom Serialize/Deserialize impls for wrapper types","Keep an NBT-representable sealed trait for your config data model"],"tags":["minecraft","nbt","serde","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}