{"record":{"id":"08a4ccaa1810d1d2","repo":"tonhowtf/omniget","slug":"ollama-delete-http","errorCode":null,"errorMessage":"ollama delete: HTTP {}","messagePattern":"ollama delete: HTTP (.+?)","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/ollama.rs","lineNumber":199,"sourceCode":"                \"done\"\n            } else {\n                \"progress\"\n            };\n            super::report(&progress, &id, stage, done, total, Some(status));\n        }\n    }\n    Ok(())\n}\n\npub async fn delete(host: &str, name: &str) -> anyhow::Result<()> {\n    let client = super::client()?;\n    let resp = client\n        .delete(format!(\"{}/api/delete\", base(host)))\n        .json(&serde_json::json!({ \"model\": name }))\n        .send()\n        .await?;\n    if !resp.status().is_success() {\n        return Err(anyhow!(\"ollama delete: HTTP {}\", resp.status()));\n    }\n    Ok(())\n}\n","sourceCodeStart":181,"sourceCodeEnd":203,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/ollama.rs#L181-L203","documentation":"`ollama::delete` sends DELETE `{host}/api/delete` with `{\"model\": name}`; a non-success HTTP status aborts with 'ollama delete: HTTP <status>'. Commonly a 404 when the model is not present on that server, or 400/500 for malformed names or server-side failures.","triggerScenarios":"Calling `delete(host, name)` for a model that does not exist on the server (404), with an empty/malformed model name (400/404), or when the server is down/misrouted and a proxy responds with an error status.","commonSituations":"Trying to remove a model already deleted or never pulled on this host; wrong host/port so the request hits something other than Ollama; name missing the tag you actually pulled (e.g. 'llama3' vs 'llama3:8b').","solutions":["Confirm the model exists first by listing models (`GET /api/tags` or the app's status listing) before deleting; treat 404 as already-deleted success if idempotency is desired.","Check the exact model tag matches what `/api/tags` reports (include the size suffix).","Verify the Ollama server is reachable at `base(host)` with `curl http://<host>/api/version`."],"exampleFix":"// before\nollama::delete(host, name).await?;\n// after\nmatch ollama::delete(host, name).await {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"404\") => { /* already gone; ignore */ }\n    Err(e) => return Err(e),\n}","handlingStrategy":"validation","validationCode":"let tags = reqwest::Client::new()\n    .get(format!(\"http://{host}/api/tags\")).send().await?\n    .json::<serde_json::Value>().await?;\nlet exists = tags[\"models\"].as_array().map(|m| {\n    m.iter().any(|v| v[\"name\"].as_str() == Some(name))\n}).unwrap_or(false);\nif !exists { return Ok(()); } // nothing to delete, treat as success","typeGuard":null,"tryCatchPattern":"match ollama::delete(host, name).await {\n    Ok(()) => {},\n    Err(e) if e.to_string().contains(\"HTTP 404 Not Found\") => { /* already deleted */ }\n    Err(e) => return Err(e),\n}","preventionTips":["List models via /api/tags before deleting; skip or no-op when absent for idempotency.","Match exact tags as reported by /api/tags (name includes the :size suffix).","Health-check the server before delete calls to distinguish server-down from model-not-found."],"tags":["ollama","http","delete","api"],"backgroundTag":"http-error-response","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}