{"record":{"id":"a14a21f8602aa305","repo":"Zackriya-Solutions/meetily","slug":"invalid-model-file-magic-number-doesn-t-matc","errorCode":null,"errorMessage":"Invalid model file: magic number {:?} doesn't match GGUF/GGML","messagePattern":"Invalid model file: magic number (.+?) doesn't match GGUF/GGML","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src-tauri/src/summary/summary_engine/model_manager.rs","lineNumber":788,"sourceCode":"    }\n\n    /// Validate that a file is a valid GGUF model\n    async fn validate_gguf_file(&self, path: &PathBuf) -> Result<()> {\n        let mut file = fs::File::open(path).await?;\n\n        // Read first 4 bytes to check for GGUF magic number\n        use tokio::io::AsyncReadExt;\n        let mut magic = [0u8; 4];\n        file.read_exact(&mut magic).await?;\n\n        // GGUF magic number is \"GGUF\" (0x47475546)\n        if &magic == b\"GGUF\" {\n            Ok(())\n        } else if &magic == b\"ggjt\" || &magic == b\"ggla\" || &magic == b\"ggml\" {\n            // Older formats (GGML, GGJT)\n            Ok(())\n        } else {\n            Err(anyhow!(\n                \"Invalid model file: magic number {:?} doesn't match GGUF/GGML\",\n                magic\n            ))\n        }\n    }\n\n    /// Cancel an ongoing download\n    pub async fn cancel_download(&self, model_name: &str) -> Result<()> {\n        log::info!(\"Cancelling download for model: {}\", model_name);\n\n        // Set cancellation flag - download loop will detect this and handle cleanup\n        {\n            let mut cancel_flag = self.cancel_download_flag.write().await;\n            *cancel_flag = Some(model_name.to_string());\n        }\n\n        // Note: active_downloads cleanup is handled by the download loop when it detects\n        // the cancellation flag. This avoids double-removal race condition.","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/summary/summary_engine/model_manager.rs#L770-L806","documentation":"validate_model_file reads the first 4 bytes and requires the magic 'GGUF' (or a legacy 'ggjt'/'ggla'/'ggml'). Any other bytes produce this error: the file at the model path is not a GGUF model - most commonly an HTML error page that was saved in place of the binary.","triggerScenarios":"Post-download validation or load reads a file whose header is not GGUF/GGML: a 404/redirect/auth-wall HTML page saved as the .gguf, a corrupted first block from a bad resume, or a user manually placing a non-GGUF file in the models/summary directory.","commonSituations":"HuggingFace/LFS redirect or CDN error page saved instead of the binary, captive portal intercepting the download, renaming a .bin or .onnx file to .gguf, partial-file resume where offsets shifted.","solutions":["Delete the bad file via delete_model and re-download","Check the URL actually returns the binary: curl -sL <url> | head -c 4 should print GGUF","If installing manually, verify with xxd -l 4 <file> that it shows 47475546 ('GGUF') and name it exactly as model_def.gguf_file","Clear proxy/CDN/auth interference (captive portals, authenticated mirrors) and retry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Cheap magic check before trusting any model file\nfn is_gguf_file(path: &Path) -> bool {\n    use std::io::Read;\n    let mut f = match std::fs::File::open(path) { Ok(f) => f, Err(_) => return false };\n    let mut magic = [0u8; 4];\n    f.read_exact(&mut magic).is_ok() && (&magic == b\"GGUF\" || &magic == b\"ggml\" || &magic == b\"ggjt\" || &magic == b\"ggla\")\n}","typeGuard":"fn is_valid_model_file(path: &Path) -> bool {\n    std::fs::metadata(path).map(|m| m.is_file()).unwrap_or(false) && is_gguf_file(path)\n}","tryCatchPattern":"try { manager.download_model(name).await? }\ncatch (e) if e.to_string().contains(\"magic number\") {\n    // an HTML error page or wrong file was saved - delete and re-download from the canonical URL\n    manager.delete_model(name).await.ok();\n    manager.download_model(name).await?;\n}","preventionTips":["Validate the magic bytes on any manually installed model before first run","curl -sL <model url> | head -c 4 must print GGUF before relying on the URL","Never rename non-GGUF files to .gguf; the loader checks content, not extension"],"tags":["gguf","validation","download","model-manager","file-format"],"backgroundTag":"invalid-file-format","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}