{"record":{"id":"c6f943ff2a5caf58","repo":"tonhowtf/omniget","slug":"ollama-pull-http","errorCode":null,"errorMessage":"ollama pull: HTTP {}","messagePattern":"ollama pull: HTTP (.+?)","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/ollama.rs","lineNumber":157,"sourceCode":"                    .collect();\n            }\n        }\n    }\n    st\n}\n\npub async fn pull(host: &str, name: &str, progress: super::ProgressFn) -> anyhow::Result<()> {\n    use futures::StreamExt;\n    let b = base(host);\n    let client = super::client()?;\n    let id = format!(\"ollama-pull:{}\", name);\n    let resp = client\n        .post(format!(\"{}/api/pull\", b))\n        .json(&serde_json::json!({ \"model\": name, \"stream\": true }))\n        .send()\n        .await?;\n    if !resp.status().is_success() {\n        return Err(anyhow!(\"ollama pull: HTTP {}\", resp.status()));\n    }\n    let mut stream = resp.bytes_stream();\n    let mut buf = String::new();\n    while let Some(chunk) = stream.next().await {\n        let chunk = chunk?;\n        buf.push_str(&String::from_utf8_lossy(&chunk));\n        while let Some(pos) = buf.find('\\n') {\n            let line = buf[..pos].trim().to_string();\n            buf.drain(..=pos);\n            if line.is_empty() {\n                continue;\n            }\n            let v: serde_json::Value = match serde_json::from_str(&line) {\n                Ok(v) => v,\n                Err(_) => continue,\n            };\n            if let Some(err) = v[\"error\"].as_str() {\n                return Err(anyhow!(\"ollama: {}\", err));","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/ollama.rs#L139-L175","documentation":"`ollama::pull` POSTs to `{host}/api/pull` with `stream: true`; if the HTTP response status is not a success (2xx), it aborts with 'ollama pull: HTTP <status>'. This surfaces any server-side rejection of the pull request before the streaming progress loop begins.","triggerScenarios":"Calling `pull(host, name, progress)` when the Ollama server responds with a non-2xx status: 404 for an unknown model/registry, 400 for a malformed model name, 500 for registry/disk errors, or a proxy returning 502/503.","commonSituations":"Ollama server not running or at a different port than `base(host)` assumes; typo in the model name (e.g. 'llama3.1' vs 'llama3.1:8b'); corporate proxy blocking registry.ollama.ai; server version too old for the requested model.","solutions":["Check the Ollama server is up: `curl http://localhost:11434/api/version` (adjust host/port).","Verify the exact model tag exists on the registry (`ollama pull <name>` manually or search ollama.com/library) and retry with the full tag including the size suffix.","Read the status code: 404 -> fix the model name; 5xx -> check server logs / disk space; 403/407 -> fix proxy configuration."],"exampleFix":"// before\nollama::pull(\"localhost:11434\", \"llama3\", progress).await?;\n// after\nlet status = reqwest::get(\"http://localhost:11434/api/version\").await;\nif status.is_err() {\n    return Err(anyhow!(\"ollama server nao esta rodando em localhost:11434\"));\n}\nollama::pull(\"localhost:11434\", \"llama3:8b\", progress).await?;","handlingStrategy":"retry","validationCode":"let base = format!(\"http://{host}\");\nlet ping = reqwest::Client::new().get(format!(\"{base}/api/version\")).send().await?;\nif !ping.status().is_success() {\n    return Err(anyhow!(\"ollama server inacessivel em {host}\"));\n}","typeGuard":null,"tryCatchPattern":"for attempt in 0..3 {\n    match ollama::pull(host, name, progress.clone()).await {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"HTTP 5\") && attempt < 2 => tokio::time::sleep(std::time::Duration::from_secs(2)).await,\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Health-check the Ollama server (/api/version) before pull/delete operations.","Use full model tags including size suffix (e.g. llama3.1:8b) verified against ollama.com/library.","Configure proxy env vars explicitly if the server must reach registry.ollama.ai through a proxy."],"tags":["ollama","http","network","pull"],"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-15T23:17:13.987Z"}