{"record":{"id":"78400905b7298f31","repo":"janhq/jan","slug":"invalid-metadata-embedding-length-not-found-or-in","errorCode":null,"errorMessage":"Invalid metadata: embedding_length not found or invalid","messagePattern":"Invalid metadata: embedding_length not found or invalid","errorType":"error_code","errorClass":"KVCacheError::EmbeddingLengthInvalid","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/fad3f12a147d138388a66f0d92a02b2675f65294/src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs#L51-L87","documentation":"`KVCacheError::EmbeddingLengthInvalid` — the estimator could not find or parse the model embedding/hidden dimension (e.g. `llama.embedding_length`). This is the per-element width used to size each KV-cache entry.","triggerScenarios":"The `<arch>.embedding_length` key is missing from the parsed metadata, or its value does not parse to an integer. Some architectures expose this under a different name (e.g. `hidden_size`, `n_embd`).","commonSituations":"Architecture-specific key naming differences; stripped metadata; a value stored as a float string that fails integer parsing. The error fires after architecture and block_count have already been resolved, so the file is mostly valid but missing this one field.","solutions":["Dump `<arch>.*` and find the key holding the hidden dimension; add it as a fallback.","Parse defensively with trim and float-tolerant parse.","Re-download or pick a known-good GGUF if the field is genuinely absent.","Confirm the architecture name matches the key prefix your lookup uses."],"exampleFix":"// before\nlet d: u64 = meta.metadata.get(&format!(\"{}.embedding_length\", arch))\n    .ok_or(KVCacheError::EmbeddingLengthInvalid)?\n    .parse().map_err(|_| KVCacheError::EmbeddingLengthInvalid)?;\n\n// after - synonym fallbacks\nlet d: u64 = [\"embedding_length\", \"n_embd\", \"hidden_size\"].iter()\n    .find_map(|k| meta.metadata.get(&format!(\"{}.{}\", arch, k)))\n    .ok_or(KVCacheError::EmbeddingLengthInvalid)?\n    .trim().parse().map_err(|_| KVCacheError::EmbeddingLengthInvalid)?;","handlingStrategy":"validation","validationCode":"fn embedding_len(meta: &GgufMetadata, arch: &str) -> Option<u64> {\n    [\"embedding_length\", \"n_embd\", \"hidden_size\"].iter()\n        .find_map(|k| meta.metadata.get(&format!(\"{arch}.{k}\")))\n        .and_then(|s| s.trim().parse::<u64>().ok())\n}","typeGuard":"null","tryCatchPattern":"match estimate_kv_cache(&meta) {\n    Ok(est) => Ok(est),\n    Err(KVCacheError::EmbeddingLengthInvalid) => Err(UserError::UnsupportedModel(\"missing embedding_length\".into())),\n    Err(e) => Err(e.into()),\n}","preventionTips":["Add synonym fallbacks for hidden-size naming across architectures.","Parse defensively.","Log the resolved architecture's full key set during estimate."],"tags":["gguf","metadata","embedding","kvcache","llamacpp","rust"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}