Pumpkin-MC/Pumpkin · error · Error
NBT doesn't support this type
Error message
NBT doesn't support this type: {0} What it means
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.
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.
Example fix
// before
struct Data { id: u128 }
// after
struct Data { id: i64 } Defensive patterns
Strategy: type-guard
Validate before calling
// Rust: restrict your data model to NBT-representable types
fn nbt_repr<'a, T: Serialize>(v: &'a T) {} // compile-time check via a dedicated trait if available Try / catch
match value.to_nbt() {
Err(pumpkin_nbt::Error::UnsupportedType(t)) => eprintln!("type {t} cannot be stored in NBT"),
Err(e) => return Err(e.into()),
Ok(tag) => tag,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Serde error
- The root tag of the NBT file is not a compound tag…
- Encountered an unknown NBT tag id
- Failed to Cesu 8 Decode
- Failed to UTF-8 Decode
AI-assisted analysis of Pumpkin-MC/Pumpkin@8d4639e25a (2026-09-09).
Data as JSON: /api/errors/b242c9fedc1518dc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/pumpkin-nbt/src/lib.rs:89
#[derive(Error, Debug)]
pub enum Error {
/// The root tag was not a compound tag and contains the reported tag ID.
#[error("The root tag of the NBT file is not a compound tag. Received tag id: {0}")]
NoRootCompound(u8),
/// A tag ID not defined by the NBT format was encountered.
#[error("Encountered an unknown NBT tag id: {0}.")]
UnknownTagId(u8),
/// A Java CESU-8 string could not be decoded.
#[error("Failed to Cesu 8 Decode")]
Cesu8DecodingError,
/// A string could not be decoded as UTF-8.
#[error("Failed to UTF-8 Decode")]
Utf8DecodingError,
/// Serde reported an invalid value or serializer state.
#[error("Serde error: {0}")]
SerdeError(String),
/// The requested Rust type has no NBT representation.
#[error("NBT doesn't support this type: {0}")]
UnsupportedType(String),
/// The underlying reader or writer returned an I/O error.
#[error("NBT reading was cut short: {0}")]
Incomplete(io::Error),
/// A list or array declared a negative element count.
#[error("Negative list length: {0}")]
NegativeLength(i32),
/// A string, list, or array exceeded the supported length.
#[error("Length too large: {0}")]
LargeLength(usize),
/// A Bedrock variable-length integer exceeded its maximum encoded size.
#[error("Failed to decode varint - value too large")]
VarIntTooLarge,
/// A Bedrock variable-length long exceeded its maximum encoded size.
#[error("Failed to decode varlong - value too large")]
VarLongTooLarge,
/// NBT nesting depth exceeded the maximum allowed limit.
#[error("NBT depth exceeded maximum allowed limit")]View on GitHub (pinned to 8d4639e25a)