tonhowtf/omniget · error · anyhow
ollama delete: HTTP
Error message
ollama delete: HTTP {} What it means
`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.
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`.
Example fix
// before
ollama::delete(host, name).await?;
// after
match ollama::delete(host, name).await {
Ok(()) => {},
Err(e) if e.to_string().contains("404") => { /* already gone; ignore */ }
Err(e) => return Err(e),
} Defensive patterns
Strategy: validation
Validate before calling
let tags = reqwest::Client::new()
.get(format!("http://{host}/api/tags")).send().await?
.json::<serde_json::Value>().await?;
let exists = tags["models"].as_array().map(|m| {
m.iter().any(|v| v["name"].as_str() == Some(name))
}).unwrap_or(false);
if !exists { return Ok(()); } // nothing to delete, treat as success Try / catch
match ollama::delete(host, name).await {
Ok(()) => {},
Err(e) if e.to_string().contains("HTTP 404 Not Found") => { /* already deleted */ }
Err(e) => return Err(e),
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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').
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/08a4ccaa1810d1d2.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/ollama.rs:199
"done"
} else {
"progress"
};
super::report(&progress, &id, stage, done, total, Some(status));
}
}
Ok(())
}
pub async fn delete(host: &str, name: &str) -> anyhow::Result<()> {
let client = super::client()?;
let resp = client
.delete(format!("{}/api/delete", base(host)))
.json(&serde_json::json!({ "model": name }))
.send()
.await?;
if !resp.status().is_success() {
return Err(anyhow!("ollama delete: HTTP {}", resp.status()));
}
Ok(())
}
View on GitHub (pinned to 8600b91f42)