{"record":{"id":"8db1fb1dc3c17e2b","repo":"tonhowtf/omniget","slug":"modelo-desconhecido","errorCode":null,"errorMessage":"modelo desconhecido: {}","messagePattern":"modelo desconhecido: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/whisper.rs","lineNumber":87,"sourceCode":"                label: id\n                    .replace('-', \" \")\n                    .replace(\"q5_0\", \"(q5)\")\n                    .replace(\"q5_1\", \"(q5)\"),\n                size_mb: *mb,\n                note: note.to_string(),\n                installed: size > 0,\n                path: path\n                    .filter(|_| size > 0)\n                    .map(|p| p.to_string_lossy().to_string()),\n                size_bytes: size,\n            }\n        })\n        .collect()\n}\n\npub async fn download_model(id: &str, progress: ProgressFn) -> anyhow::Result<PathBuf> {\n    if !MODELS.iter().any(|(m, _, _)| *m == id) {\n        return Err(anyhow!(\"modelo desconhecido: {}\", id));\n    }\n    let dir = models_dir().ok_or_else(|| anyhow!(\"Could not determine data directory\"))?;\n    std::fs::create_dir_all(&dir)?;\n    let dest = dir.join(format!(\"ggml-{}.bin\", id));\n    let url = format!(\"{}/ggml-{}.bin\", HF_BASE, id);\n    let client = super::client()?;\n    super::download_to(\n        &client,\n        &url,\n        &dest,\n        &progress,\n        &format!(\"whisper-model:{}\", id),\n    )\n    .await?;\n    Ok(dest)\n}\n\npub fn remove_model(id: &str) -> anyhow::Result<()> {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/whisper.rs#L69-L105","documentation":"download_model validates the requested model id against the static MODELS table and throws 'modelo desconhecido: {}' (unknown model) if the id is not present. It guards against downloading arbitrary or misspelled model names from Hugging Face.","triggerScenarios":"Calling download_model with an id string that is not one of the known MODELS entries: typo, stale UI list, or a model id invented by an LLM/tool caller.","commonSituations":"Typing 'whisper-large-v3-turbo' when only specific ggml ids are supported, old persisted settings referencing a model removed from MODELS, or a command-line argument passed straight through without validation.","solutions":["Call the list-models function (the fn collecting over MODELS above download_model) and pick a valid id from it.","Check for typos or version suffixes in the id; ids must exactly match the MODELS table.","Update persisted user settings/migrations that reference removed model ids.","If a new model is genuinely needed, add it to the MODELS constant with its size and URL."],"exampleFix":"// before\nlet model_id = \"whisper-big\";\ndownload_model(model_id, progress).await?;\n// after\nlet model_id = \"base\"; // must be one of the ids listed by the list-models API\nassert!(whisper::list_models().iter().any(|m| m.id == model_id));\ndownload_model(model_id, progress).await?;","handlingStrategy":"validation","validationCode":"const VALID_MODELS: &[&str] = &[\"tiny\", \"base\", \"small\", \"medium\", \"large\"];\nfn is_known_model(id: &str) -> bool { VALID_MODELS.contains(&id) }\n// call: if !is_known_model(user_id) { return Err(...) }","typeGuard":"fn is_known_model(id: &str) -> bool {\n    whisper::list_models().iter().any(|m| m.id == id)\n}","tryCatchPattern":"match download_model(id, progress).await {\n    Err(e) if e.to_string().starts_with(\"modelo desconhecido\") => {\n        eprintln!(\"unknown model '{}'; available: {:?}\", id,\n            whisper::list_models().iter().map(|m| m.id).collect::<Vec<_>>());\n    }\n    other => other?,\n}","preventionTips":["Always source model ids from the list-models API, never from free-text input.","Normalize/trim user-provided ids and check membership before download.","Migrate persisted settings when MODELS entries are added or removed.","Show the valid id list in UI error messages instead of failing silently."],"tags":["validation","whisper","rust","invalid-argument"],"backgroundTag":"invalid-enum-value","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}