{"record":{"id":"22c93f86c27bbeda","repo":"janhq/jan","slug":"architecturenotfound","errorCode":"ArchitectureNotFound","errorMessage":"Invalid metadata: architecture not found","messagePattern":"Invalid metadata: architecture not found","errorType":"error_code","errorClass":"KVCacheError","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/7205d770c1e097c3daf35a911176410e93bc5564/src-tauri/plugins/tauri-plugin-llamacpp/src/gguf/types.rs#L45-L81","documentation":"KVCacheError::ArchitectureNotFound is returned when estimating KV-cache size from GGUF metadata but the required `general.architecture` key is missing from the parsed KV map. Without the architecture name the estimator cannot select the per-layer layout, so it refuses rather than guessing.","triggerScenarios":"Calling a KV-cache estimation routine on a GgufMetadata whose metadata HashMap has no `general.architecture` entry - the file has an empty KV section or the key was stripped by a converter.","commonSituations":"Minimal or hand-built GGUF files without metadata, conversion tools that drop KV entries, reading a shard or file type that carries no model metadata.","solutions":["Re-export the model so `general.architecture` is written into the KV metadata (standard llama.cpp conversions always include it)","Fall back to the caller's known architecture (pass it explicitly instead of deriving it from the file)","Check with gguf_dump whether the key exists under a different name (e.g. old 'general.architecture' variants)","If handling programmatically, map this variant to a user-facing 'unsupported/unannotated model file' message"],"exampleFix":"// before\nlet meta = read_gguf_metadata(File::open(\"bare.gguf\")?)?;\nlet est = estimate_kv_cache(&meta)?; // ArchitectureNotFound\n// after\nlet meta = read_gguf_metadata(File::open(\"bare.gguf\")?)?;\nif !meta.metadata.contains_key(\"general.architecture\") {\n    log::warn!(\"model lacks architecture metadata; using configured default\");\n    return estimate_kv_cache_for(arch_from_config, &meta);\n}\nlet est = estimate_kv_cache(&meta)?;","handlingStrategy":"fallback","validationCode":"fn has_architecture(meta: &GgufMetadata) -> bool {\n    meta.metadata.contains_key(\"general.architecture\")\n}\n// check before calling the KV-cache estimator","typeGuard":null,"tryCatchPattern":"match estimate_kv_cache(&meta) {\n    Err(KVCacheError::ArchitectureNotFound) => {\n        eprintln!(\"model file has no architecture metadata; provide it explicitly\");\n    }\n    other => other?,\n}","preventionTips":["Prefer standard llama.cpp-converted GGUF files, which always write general.architecture","Check for the key with gguf_dump before estimating KV usage","Allow callers to supply the architecture explicitly as a fallback"],"tags":["gguf","metadata","kv-cache","missing-key"],"backgroundTag":"missing-config-key","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"}