{"record":{"id":"4b9c8bb3fa8f7b02","repo":"aaif-goose/goose","slug":"model-not-found","errorCode":null,"errorMessage":"Model not found: {}","messagePattern":"Model not found: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/goose-local-inference/src/local_model_registry.rs","lineNumber":578,"sourceCode":"        let plan = self.deletion_plan(id)?;\n        delete_model_artifacts(&plan)?;\n\n        if is_featured_model(id) {\n            if let Some(entry) = self.models.iter_mut().find(|m| m.id == id) {\n                entry.local_path = Paths::in_data_dir(\"models\").join(&entry.filename);\n                entry.storage = LocalModelStorage::GooseManaged;\n                entry.shard_files.clear();\n            }\n            self.save()\n        } else {\n            self.remove_model(id)\n        }\n    }\n\n    fn deletion_plan(&self, id: &str) -> Result<ModelDeletionPlan> {\n        let entry = self\n            .get_model(id)\n            .ok_or_else(|| anyhow::anyhow!(\"Model not found: {}\", id))?;\n        let mmproj_path = entry.mmproj_path.clone();\n        let other_uses_mmproj = mmproj_path.as_ref().is_some_and(|target| {\n            self.models\n                .iter()\n                .any(|m| m.id != id && m.is_downloaded() && m.mmproj_path.as_ref() == Some(target))\n        });\n\n        Ok(ModelDeletionPlan {\n            all_paths: entry.all_local_paths().map(|p| p.to_path_buf()).collect(),\n            primary_path: entry.local_path.clone(),\n            mmproj_path,\n            delete_mmproj: entry.storage == LocalModelStorage::GooseManaged && !other_uses_mmproj,\n        })\n    }\n\n    pub fn get_model(&self, id: &str) -> Option<&LocalModelEntry> {\n        self.models.iter().find(|m| m.id == id)\n    }","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-local-inference/src/local_model_registry.rs#L560-L596","documentation":"LocalModelRegistry::delete_model builds a deletion plan via deletion_plan, which looks the id up with get_model; if no registry entry carries that id it bails with 'Model not found'. Ids are synthesized from repo_id plus quantization (model_id_from_repo), so near-miss ids are the usual cause. Nothing is deleted when this fires.","triggerScenarios":"Calling delete_model with an id that was never registered, was already deleted (double-delete), or was built differently than the registry's id (different quantization suffix, casing, or owner).","commonSituations":"Stale UI list after a delete from another window/device; retrying a delete that already succeeded; ids reconstructed by hand instead of taken from list_models.","solutions":["Check has_model(id) or refresh from list_models() and pass the exact stored id","If your delete should be idempotent, treat this specific 'Model not found' as success","Reconcile the UI model list with the registry before offering delete actions"],"exampleFix":"// before\nregistry.delete_model(model_id)?;\n\n// after: idempotent delete with a precise error\nif !registry.has_model(model_id) {\n    log::debug!(\"model {model_id} already gone\");\n    return Ok(());\n}\nregistry.delete_model(model_id)?;","handlingStrategy":"validation","validationCode":"if !registry.has_model(model_id) {\n    // stale id or double delete: refresh from list_models() or treat as done\n    return Ok(());\n}\nregistry.delete_model(model_id)?;","typeGuard":"fn model_id_exists(registry: &LocalModelRegistry, id: &str) -> bool {\n    registry.has_model(id)\n}","tryCatchPattern":"match registry.delete_model(id) {\n    Err(e) if e.to_string().starts_with(\"Model not found\") => {\n        // already deleted: treat as success for idempotent flows, or refresh the list\n    }\n    other => other,\n}","preventionTips":["Always source ids from list_models()/get_model(), never reconstruct them","Make delete flows idempotent by swallowing this specific not-found error","Refresh the model list after any delete before rendering actions again"],"tags":["rust","registry","not-found","local-inference","validation"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}