{"record":{"id":"d20823d4a66cf068","repo":"janhq/jan","slug":"embeddinglengthinvalid","errorCode":"EmbeddingLengthInvalid","errorMessage":"Invalid metadata: embedding_length not found or invalid","messagePattern":"Invalid metadata: embedding_length not found or invalid","errorType":"error_code","errorClass":"KVCacheError","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs","lineNumber":69,"sourceCode":"    pub version: u32,\n    pub tensor_count: u64,\n    pub metadata: HashMap<String, String>,\n}\n\n#[derive(Debug, Serialize, Deserialize)]\npub struct KVCacheEstimate {\n    pub size: u64,\n    pub per_token_size: u64,\n}\n#[derive(Debug, thiserror::Error)]\npub enum KVCacheError {\n    #[error(\"Invalid metadata: architecture not found\")]\n    ArchitectureNotFound,\n    #[error(\"Invalid metadata: block_count not found or invalid\")]\n    BlockCountInvalid,\n    #[error(\"Invalid metadata: head_count not found or invalid\")]\n    HeadCountInvalid,\n    #[error(\"Invalid metadata: embedding_length not found or invalid\")]\n    EmbeddingLengthInvalid,\n    #[error(\"Invalid metadata: context_length not found or invalid\")]\n    ContextLengthInvalid,\n}\n\nimpl serde::Serialize for KVCacheError {\n    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>\n    where\n        S: serde::Serializer,\n    {\n        serializer.serialize_str(&self.to_string())\n    }\n}\n\n\n#[derive(Debug, Clone, Copy, PartialEq, serde::Serialize)]\npub enum ModelSupportStatus {\n    #[serde(rename = \"RED\")]","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/janhq/jan/blob/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs#L51-L87","documentation":"KVCacheError::EmbeddingLengthInvalid is raised when GGUF metadata is missing a valid `embedding_length` (hidden size) key. The plugin needs this value to compute the size of each token's embedding/KV entries, so it fails when the key is absent or not an integer. It signals a malformed or unsupported GGUF file.","triggerScenarios":"Loading a GGUF model whose metadata map lacks `{arch}.embedding_length`, or where the stored value cannot be read as the expected numeric type during KV-cache initialization.","commonSituations":"Truncated downloads; custom conversion pipelines that skip standard metadata keys; architectures with different metadata naming that the reader doesn't map.","solutions":["Re-download or re-extract the GGUF model and verify its checksum.","Inspect metadata with gguf-dump to confirm `embedding_length` exists and is a positive integer.","Re-run the model conversion with the latest llama.cpp scripts so full metadata is emitted.","Update tauri-plugin-llamacpp if the model's architecture uses an unrecognized metadata prefix."],"exampleFix":"// before\nlet emb_len = md.embedding_length(); // panics/errors when key absent\n\n// after\nlet emb_len = match md.get(\"llama.embedding_length\") {\n    Some(v) => *v,\n    None => anyhow::bail!(\"GGUF missing embedding_length; re-convert model with current llama.cpp\"),\n};","handlingStrategy":"validation","validationCode":"// Rust: confirm embedding_length exists before cache init\nfn has_embedding_length(md: &GgufMetadata, arch: &str) -> bool {\n    md.get_u64(&format!(\"{arch}.embedding_length\")).map(|v| v > 0).unwrap_or(false)\n}","typeGuard":"fn valid_u64(v: Option<&u64>) -> bool {\n    matches!(v, Some(n) if *n > 0)\n}","tryCatchPattern":"match kv_cache::from_gguf(&path) {\n    Err(KVCacheError::EmbeddingLengthInvalid) => anyhow::bail!(\"GGUF missing embedding_length; re-convert model\"),\n    other => other?,\n}","preventionTips":["Sanity-check all required GGUF keys (block/head/embedding/context) together in one preflight function.","Reject suspiciously small values (e.g. 0) during preflight.","Keep conversion tooling up to date so metadata is complete."],"tags":["gguf","rust","model-loading","metadata"],"backgroundTag":"missing-required-config-field","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"}