Skip to content

fix(embeddings): silence Ollama-not-running Sentry noise (OPENHUMAN-TAURI-B7) - #1546

Closed
CodeGhost21 wants to merge 1 commit into
tinyhumansai:mainfrom
CodeGhost21:fix/ollama-embed-transport-noise
Closed

CodeGhost21 wants to merge 1 commit into
tinyhumansai:mainfrom
CodeGhost21:fix/ollama-embed-transport-noise

Conversation

@CodeGhost21

@CodeGhost21 CodeGhost21 commented May 12, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Transport-layer failures from the Ollama embedding provider (localhost:11434 connection refused / DNS / timeout) no longer report to Sentry — they were generating 226 events/day across 0 impacted users, all from a perfectly normal state: the user simply hasn't installed Ollama.
  • Non-2xx HTTP responses (Ollama is up but errored) still funnel through report_error — those remain actionable.
  • Callers still receive the same anyhow::Error with the "is Ollama running at <url>?" message; only the Sentry side effect is removed and the log severity is reduced from error to warn.

Problem

Sentry issue OPENHUMAN-TAURI-B7 (link) was firing on every embed call for any user who didn't have Ollama running locally — 226 occurrences in a single day, 0 users affected by an actual product defect. Every embed retry generated another event, drowning out genuine alerts. Local-provider "server isn't installed" is an expected user environment state, not a bug.

Solution

In src/openhuman/embeddings/ollama.rs the .send() failure branch previously called crate::core::observability::report_error(...), which is a thin wrapper around tracing::error! + sentry::with_scope. Switched that branch to a direct tracing::warn! with the same structured fields (domain, operation, failure=transport, model). The sentry-tracing integration captures error-level events; warn is logged locally but not forwarded. The non-2xx branch is unchanged.

Test embed_connection_refused already covers this path — the assertion on the returned error message still passes because we only removed the Sentry side effect, not the anyhow! return.

Submission Checklist

  • Tests added or updated — existing embed_connection_refused covers the transport-failure path; assertion on the user-visible error message is unchanged.
  • Diff coverage ≥ 80% — 14 changed lines in ollama.rs; transport-failure branch covered by embed_connection_refused, non-2xx branch still covered by embed_server_error_with_body / embed_server_error_empty_body.
  • Coverage matrix updated — N/A: behaviour-only change to observability path, no feature added/removed/renamed.
  • All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: no matrix entries touched.
  • No new external network dependencies introduced.
  • Manual smoke checklist updated if this touches release-cut surfaces — N/A: no release-cut surface touched.
  • Linked issue closed via Closes #NNN — N/A: tracked in Sentry (Fixes OPENHUMAN-TAURI-B7), not GitHub Issues.

Impact

  • Desktop only (Ollama embeddings provider is only invoked from the core sidecar).
  • Performance: nil — the error path is rare and now does strictly less work.
  • Security/migration/compat: none.
  • Operational: Sentry signal-to-noise on openhuman-tauri improves substantially; one of the top noisy issues stops firing.

Related

  • Closes: Fixes OPENHUMAN-TAURI-B7 (Sentry)
  • Follow-up PR(s)/TODOs: none

AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

Commit & Branch

  • Branch: fix/ollama-embed-transport-noise
  • Commit SHA: c91afff7cc11779daee226467dc3639215b54b2e

Validation Run

  • pnpm --filter openhuman-app format:check — passed in pre-push hook
  • pnpm typecheck — passed in pre-push hook
  • Focused tests: cargo test --lib openhuman::embeddings::ollama → 23 passed, 0 failed
  • Rust fmt/check (if changed): cargo fmt -- --check passed; cargo check clean (only pre-existing unrelated warnings)
  • Tauri fmt/check (if changed): N/A — no Tauri shell files touched

Validation Blocked

  • N/A

Behavior Changes

  • Intended behavior change: stop emitting Sentry events when Ollama isn't running locally.
  • User-visible effect: none — the embed call still fails with the same anyhow::Error (is Ollama running at <url>?); only a server-side telemetry side-effect is removed and the local log severity drops from error to warn.

Parity Contract

  • Legacy behavior preserved: returned error type and message unchanged; non-2xx Sentry reporting unchanged.
  • Guard/fallback/dispatch parity checks: transport-failure error message format is byte-identical to the previous version; embed_connection_refused assertion still passes.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none
  • Canonical PR: this one
  • Resolution: N/A

Summary by CodeRabbit

  • Chores
    • Enhanced error logging for Ollama embedding failures with improved diagnostic information when connection issues occur.

Review Change Stack

…AN-TAURI-B7)

Transport-layer failures from the Ollama embedding provider (connection
refused, DNS, timeout) almost always mean the user simply doesn't have
Ollama running on `localhost:11434` — an expected environment state for
anyone who hasn't installed it. The previous code funneled those
failures through `report_error`, generating 226 Sentry events across 0
impacted users in a single day.

Downgrade transport failures to `tracing::warn!` so callers and local
logs still see them, but Sentry doesn't. Non-2xx HTTP responses keep
the existing `report_error` path because those indicate Ollama is up
and an actual server-side problem worth diagnosing.

Fixes OPENHUMAN-TAURI-B7
@CodeGhost21
CodeGhost21 requested a review from a team May 12, 2026 12:00
@coderabbitai

coderabbitai Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The embed method in Ollama embedding handler replaces report_error() with structured tracing::warn!() logging to capture transport failures (connection errors, Ollama unavailable) with contextual fields instead of centralizing error reporting.

Changes

Ollama Transport Error Observability

Layer / File(s) Summary
Transport error handling via structured logging
src/openhuman/embeddings/ollama.rs
The .send().await.map_err(...) branch logs transport failures using tracing::warn! with domain, operation, failure, and model fields, replacing the previous report_error() call while preserving error conversion.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • tinyhumansai/openhuman#1512: Modifies observability for provider HTTP failures using report_error calls — related observability/error-handling pattern change.

Poem

🐰 A log hops through the embed,
From report_error to warn! it's set,
Structured fields now shine so bright,
Transport troubles caught in tracing light! 📍

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: preventing Sentry noise by silencing expected Ollama-not-running transport errors, which matches the core change in the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openhuman/embeddings/ollama.rs (1)

168-189: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Suppress transport errors only by checking error type before skipping Sentry.

This map_err closure (lines 168–189) suppresses all .send() errors with tracing::warn!() but unconditionally skips report_error(). The comment says only connection/DNS/timeout failures should be suppressed—others like client configuration, body read, or decode errors should still alert. Use is_connect() and is_timeout() predicates to gate the suppression.

Proposed fix
         .send()
         .await
         .map_err(|e| {
             let message = format!(
                 "ollama embed request failed (is Ollama running at {}?): {e}",
                 self.base_url
             );
-            // Transport failure (connection refused, DNS, timeout) almost
-            // always means the user simply doesn't have Ollama running
-            // locally — an expected environment state, not a bug. Log a
-            // warning but skip Sentry to avoid alerting on every user
-            // without Ollama installed. Non-2xx responses below still
-            // funnel through `report_error` because those indicate Ollama
-            // is up but something is wrong.
-            tracing::warn!(
-                target: "embeddings.ollama",
-                domain = "embeddings",
-                operation = "ollama_embed",
-                failure = "transport",
-                model = %self.model,
-                "[embeddings] {message}"
-            );
+            if e.is_connect() || e.is_timeout() {
+                // Expected local-environment state (Ollama not running/reachable).
+                tracing::warn!(
+                    target: "embeddings.ollama",
+                    domain = "embeddings",
+                    operation = "ollama_embed",
+                    failure = "transport",
+                    model = %self.model,
+                    "[embeddings] {message}"
+                );
+            } else {
+                crate::core::observability::report_error(
+                    message.as_str(),
+                    "embeddings",
+                    "ollama_embed",
+                    &[
+                        ("model", self.model.as_str()),
+                        ("failure", "request_error"),
+                    ],
+                );
+            }
             anyhow::anyhow!(message)
         })?;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/openhuman/embeddings/ollama.rs` around lines 168 - 189, The map_err
closure on the Ollama embed request currently treats all send() errors as
transport failures and skips report_error; change it to inspect the
reqwest::Error (use error.is_connect() || error.is_timeout()) and only
suppress/report differently for transport errors: for transport errors call
tracing::warn! and return anyhow::anyhow!(message) without calling report_error,
but for all other errors call report_error(...) (or let it propagate) so they
still alert; update the closure around the send() call (the map_err attached to
the request send) to branch on error.is_connect()/is_timeout() and handle each
branch accordingly while keeping the existing log message and returned anyhow
error for transport cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/openhuman/embeddings/ollama.rs`:
- Around line 168-189: The map_err closure on the Ollama embed request currently
treats all send() errors as transport failures and skips report_error; change it
to inspect the reqwest::Error (use error.is_connect() || error.is_timeout()) and
only suppress/report differently for transport errors: for transport errors call
tracing::warn! and return anyhow::anyhow!(message) without calling report_error,
but for all other errors call report_error(...) (or let it propagate) so they
still alert; update the closure around the send() call (the map_err attached to
the request send) to branch on error.is_connect()/is_timeout() and handle each
branch accordingly while keeping the existing log message and returned anyhow
error for transport cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 742ab4c7-abf6-4d43-b2c7-5e099a29c351

📥 Commits

Reviewing files that changed from the base of the PR and between 7ce3193 and c91afff.

📒 Files selected for processing (1)
  • src/openhuman/embeddings/ollama.rs

@senamakel

Copy link
Copy Markdown
Member

No bro this is not how you handle a bug. you should not silence. you need to fix the root cause

@senamakel senamakel closed this May 12, 2026
@CodeGhost21

Copy link
Copy Markdown
Member Author

Closing this — silencing the symptom was the wrong call. The actual root cause is that the Ollama embedding provider is being selected on machines that don't have Ollama installed (or running). Tracking down the provider-selection logic and fixing that instead. Will open a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants