{"record":{"id":"240dadb2d46d601f","repo":"janhq/jan","slug":"error-reading-metadata-entry","errorCode":null,"errorMessage":"Error reading metadata entry {}: {}","messagePattern":"Error reading metadata entry (.+?): (.+?)","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/helpers.rs","lineNumber":113,"sourceCode":"    if &magic != b\"GGUF\" {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            \"Not a GGUF file\",\n        ));\n    }\n\n    let version = file.read_u32::<LittleEndian>()?;\n    let tensor_count = file.read_u64::<LittleEndian>()?;\n    let metadata_count = file.read_u64::<LittleEndian>()?;\n\n    let mut metadata_map = std::collections::HashMap::new();\n    for i in 0..metadata_count {\n        match read_metadata_entry(file, i) {\n            Ok((key, value)) => {\n                metadata_map.insert(key, value);\n            }\n            Err(e) => {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidData,\n                    format!(\"Error reading metadata entry {}: {}\", i, e),\n                ));\n            }\n        }\n    }\n\n    Ok(GgufMetadata {\n        version,\n        tensor_count,\n        metadata: metadata_map,\n    })\n}\n\nfn read_metadata_entry<R: Read + Seek + ReadBytesExt>(\n    reader: &mut R,\n    index: u64,\n) -> io::Result<(String, String)> {","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/helpers.rs#L95-L131","documentation":"read_header wraps any failure from read_metadata_entry for KV entry i with its index, so the offending metadata record is identified. The inner error is usually a nested string/value failure (key read, unknown value type, oversized string/array) or plain I/O failure.","triggerScenarios":"Calling read_gguf_metadata or find_gguf_tensors on a file whose KV metadata section is truncated, contains an unknown value-type tag, or has an oversized string/array - the inner message names the exact sub-cause.","commonSituations":"Corrupted model downloads, files written by newer GGUF writers using value types this parser does not know, truncated transfers, tooling that pads or edits KV sections.","solutions":["Read the inner error text (after the index) to identify the sub-cause - unknown value type, string length, or I/O error","Re-download the file and verify its checksum","If the inner error is 'Unknown GGUF value type', update the parser or re-export the model with an older gguf version","Cross-check with llama.cpp's gguf_dump to see which KV entry is malformed"],"exampleFix":"// before\nlet meta = read_gguf_metadata(file)?; // Error reading metadata entry 7: ...\n// after\nmatch read_gguf_metadata(file) {\n    Ok(m) => m,\n    Err(e) if e.to_string().contains(\"metadata entry\") => {\n        log::warn!(\"GGUF KV section corrupt: {e}; refusing model\");\n        anyhow::bail!(\"model file damaged - re-download\")\n    }\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match read_gguf_metadata(file) {\n    Err(e) if e.to_string().contains(\"metadata entry\") => {\n        // e.g. 'Error reading metadata entry 7: ...' - index names the bad KV record\n        eprintln!(\"GGUF KV section corrupt: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Parse the inner message after the entry index to pinpoint the bad record","Always verify checksums of downloaded models","Keep the parser updated for newer GGUF value types"],"tags":["gguf","metadata","corrupt-file","binary-parsing"],"backgroundTag":"file-read-failed","analyzedSha":"7205d770c1e097c3daf35a911176410e93bc5564","analyzedAt":"2026-09-17T14:27:30.100Z","contentChangedAt":"2026-09-17T14:27:30.100Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}