{"record":{"id":"b7ed5caddcd454fe","repo":"janhq/jan","slug":"invalid-metadata-architecture-not-found","errorCode":null,"errorMessage":"Invalid metadata: architecture not found","messagePattern":"Invalid metadata: architecture not found","errorType":"error_code","errorClass":"KVCacheError::ArchitectureNotFound","httpStatus":null,"severity":"error","filePath":"src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs","lineNumber":63,"sourceCode":"        }\n    }\n}\n\n#[derive(Serialize)]\npub struct GgufMetadata {\n    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    }","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/janhq/jan/blob/fad3f12a147d138388a66f0d92a02b2675f65294/src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs#L45-L81","documentation":"`KVCacheError::ArchitectureNotFound` — the KV-cache estimator could not find the `.general.architecture` metadata key in the parsed GGUF map. Architecture (e.g. `llama`, `gpt2`, `falcon`) gates all downstream sizing formulas, so its absence makes any estimate impossible.","triggerScenarios":"Calling the KV-cache estimation API on a GGUF whose metadata map lacks an entry whose key ends in `.general.architecture` (or however the lookup is keyed). This happens with stripped or partial metadata, or when the lookup uses a key prefix the file did not set.","commonSituations":"Loading a converted GGUF that omitted architecture metadata; a lookup that hard-codes a key prefix (e.g. `general.architecture` vs `<arch>.general.architecture`); a file from a converter that names keys differently. Real llama.cpp GGUFs always set `general.architecture`.","solutions":["Dump the parsed metadata map keys and confirm whether `general.architecture` (or the variant your lookup expects) is present.","If the key is present under a different prefix, update the lookup to handle both bare and prefixed forms.","Use a known-good GGUF (e.g. one from TheBloke/huggingface) to confirm the parser and lookup agree.","If metadata is genuinely absent, reject the file upstream with a clearer user-facing message rather than failing mid-estimate."],"exampleFix":"// before\nlet arch = meta.metadata.get(\"general.architecture\")\n    .ok_or(KVCacheError::ArchitectureNotFound)?;\n\n// after - try multiple key forms and report which keys exist\nlet arch = meta.metadata.get(\"general.architecture\")\n    .or_else(|| meta.metadata.keys().find(|k| k.ends_with(\".architecture\")).and_then(|k| meta.metadata.get(k)))\n    .ok_or_else(|| KVCacheError::ArchitectureNotFound)?;","handlingStrategy":"validation","validationCode":"fn has_architecture(meta: &GgufMetadata) -> bool {\n    meta.metadata.contains_key(\"general.architecture\")\n        || meta.metadata.keys().any(|k| k.ends_with(\".architecture\"))\n}","typeGuard":"fn architecture_of(meta: &GgufMetadata) -> Option<&str> {\n    meta.metadata.get(\"general.architecture\").map(|s| s.as_str())\n}","tryCatchPattern":"match estimate_kv_cache(&meta) {\n    Ok(est) => Ok(est),\n    Err(KVCacheError::ArchitectureNotFound) => {\n        Err(UserError::UnsupportedModel(\"missing general.architecture\".into()))\n    }\n    Err(e) => Err(e.into()),\n}","preventionTips":["Dump metadata keys when adding support for a new architecture.","Handle both bare and arch-prefixed key forms.","Reject stripped-metadata files at the UI layer with a clear message."],"tags":["gguf","metadata","kvcache","llamacpp","rust"],"backgroundTag":null,"analyzedSha":"fad3f12a147d138388a66f0d92a02b2675f65294","analyzedAt":"2026-08-12T20:33:47.516Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}