janhq/jan · error · io::Error

Unknown GGUF value type: {}

Error message

Unknown GGUF value type: {}

What it means

Returned by `TryFrom<u32>` for `GgufValueType` when the discriminator read from the stream is not in 0..=12. The GGUF spec assigns 0=Uint8, 1=Int8, 2=Uint16, 3=Int16, 4=Uint32, 5=Int32, 6=Float32, 7=Bool, 8=String, 9=Array, 10=Uint64, 11=Int64, 12=Float64. Any other value is rejected.

Source

Thrown at src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs:41

impl TryFrom<u32> for GgufValueType {
    type Error = io::Error;
    fn try_from(value: u32) -> Result<Self, Self::Error> {
        match value {
            0 => Ok(Self::Uint8),
            1 => Ok(Self::Int8),
            2 => Ok(Self::Uint16),
            3 => Ok(Self::Int16),
            4 => Ok(Self::Uint32),
            5 => Ok(Self::Int32),
            6 => Ok(Self::Float32),
            7 => Ok(Self::Bool),
            8 => Ok(Self::String),
            9 => Ok(Self::Array),
            10 => Ok(Self::Uint64),
            11 => Ok(Self::Int64),
            12 => Ok(Self::Float64),
            _ => Err(io::Error::new(
                io::ErrorKind::InvalidData,
                format!("Unknown GGUF value type: {}", value),
            )),
        }
    }
}

#[derive(Serialize)]
pub struct GgufMetadata {
    pub version: u32,
    pub tensor_count: u64,
    pub metadata: HashMap<String, String>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct KVCacheEstimate {
    pub size: u64,
    pub per_token_size: u64,

View on GitHub (pinned to fad3f12a14)

Solutions

  1. Look at the printed value: small numbers (13-255) suggest an unknown but plausible type extension; large numbers scream misalignment.
  2. Re-check alignment of preceding fields per the GGUF spec (lengths are u64 LE, type tags are u32 LE).
  3. Hex-dump around the failing offset to confirm the type-tag bytes.
  4. If the file is from a newer GGUF revision that added a type, update this enum to support it; otherwise re-download.

Example fix

// before
_ => Err(io::Error::new(InvalidData, format!("Unknown GGUF value type: {}", value))),

// after - distinguish known-but-unsupported from clear garbage
_ => {
    let hint = if value > 1024 { " (looks like misalignment)" } else { "" };
    Err(io::Error::new(InvalidData,
        format!("Unknown GGUF value type: {}{}", value, hint)))
}
Defensive patterns

Strategy: try-catch

Validate before calling

const KNOWN_TYPES: &[u32] = &[0,1,2,3,4,5,6,7,8,9,10,11,12];
fn is_known_value_type(v: u32) -> bool { KNOWN_TYPES.contains(&v) }

Type guard

fn is_known_value_type(v: u32) -> bool { matches!(v, 0..=12) }

Try / catch

let vt = GgufValueType::try_from(raw_u32);
match vt {
    Ok(t) => Ok(t),
    Err(e) => {
        tracing::error!("unknown GGUF value type {raw_u32} — likely misalignment");
        Err(CorruptFile(e.to_string()))
    }
}

Prevention

When it happens

Trigger: Reading the value-type discriminator (u32 LE) of a metadata entry, or the element type of an Array, and getting a value outside 0..=12. Almost always indicates stream misalignment (reading a length or data byte as a type tag) or a corrupt file. The message echoes the offending discriminator value, which is a strong diagnostic clue.

Common situations: Misalignment after an earlier field was misread; a GGUF from a buggy/older writer that emits a non-spec type tag; corruption. If the value is large (e.g. millions), it is almost certainly a misread length, not a type tag.

Related errors


AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12). Data as JSON: /api/errors/fd8caf7efd788635. Report an issue: GitHub.