fix(observability): demote loopback sidecar-down noise to expected (#R5 #R6)
Summary
- New
ExpectedErrorKind::LoopbackUnavailablefor the in-process-core boot-window race: a sibling component (frontend RPC relay, integrations / composio HTTP clients) reaches127.0.0.1:<port>before the embedded core's listener finishes binding, gets a TCPConnection refused, and currently re-reports throughreport_error_message⇒ Sentry. - Conjunctive matcher
is_loopback_unavailable—127.0.0.1:/localhost:host ANDconnection refused (os error 61 / 111 / 10061)— wired intoexpected_error_kindbeforeis_network_unreachable_messageso loopback wins precedence. - Demote arm uses
tracing::debug!with metadata-only structured fields (no raw{message}); breadcrumb survives, Sentry capture is skipped. - Closes OPENHUMAN-TAURI-R5 (~2.5k events,
integrations.getemit site) and OPENHUMAN-TAURI-R6 (~2.5k events,rpc.invoke_methodre-wrap of the same trace).
Problem
Two Sentry issues, ~5k events combined, share trace_id=6ebf5b62748d5144e541e2cddeabbbd0 — R6 is the rpc-layer wrap of R5. Both report from src/core/observability.rs via the report_error_* site:
| ID | Events | Body shape |
|---|---|---|
| OPENHUMAN-TAURI-R5 | ~2526 | integrations.get failed: error sending request for url (http://127.0.0.1:18474/agent-integrations/composio/connections) → client error (Connect) → tcp connect error → Connection refused (os error 61) |
| OPENHUMAN-TAURI-R6 | ~2471 | rpc.invoke_method failed: [composio] list_connections failed: GET http://127.0.0.1:18474/agent-integrations/composio/connections failed: error sending request for url (…) → Connection refused (os error 61) |
R5 already carries the tracing tag failure: transport, but the existing classifier has no loopback-specific arm — the body shape is the in-process core's 127.0.0.1:18474 listener not yet accepting connections during app startup. Per feedback_in_process_core_restart_noop this boot window self-resolves once the core finishes binding; no retry on the calling side can do better than waiting it out, and Sentry has no remediation path. This is the same demote-the-noise family as PR #1798 (3 transient leak paths) — leak #4.
While these bodies would also satisfy the broader is_network_unreachable_message matcher (which catches connection refused generically), folding them into NetworkUnreachable conflates an internal lifecycle race with real user-environment problems (VPN drop, captive portal, ISP block) and makes Sentry's "which class of transport failure is spiking?" signal un-answerable.
Solution
Three commits, scoped tightly to src/core/observability.rs:
-
ExpectedErrorKind::LoopbackUnavailablevariant +report_expected_messagearm — paired because Rust's exhaustivematchrequires the arm to land with the enum addition. The arm usestracing::debug!(lower thanwarn!used forNetworkUnreachable) and only logsdomain/operation/kind = "loopback_unavailable"— no raw{message}in fields or format string. Mirrors #1719 review guidance to prefer tags over body for noise demotions. -
is_loopback_unavailablematcher + ladder precedence — conjunctive substring matcher requiring both a loopback host with port (127.0.0.1:orlocalhost:) and an explicit errno ((os error 61)macOS,(os error 111)Linux,(os error 10061)WindowsWSAECONNREFUSED). Inserted into theexpected_error_kindladder beforeis_network_unreachable_messageso the loopback bucket wins — same precedence pattern asProviderUserState-before-BackendUserErrorfrom PR #1795. -
Tests — verbatim R5/R6 bodies classify as
LoopbackUnavailable; Linux + Windows errno variants both match; precedence guard asserts loopback shape ≠NetworkUnreachable; loopback URL with a 503 status (developer proxy on127.0.0.1:8080) and non-loopbackConnection refusedstay out of the loopback bucket;report_error_or_expectedroutes both R5/R6 shapes through the expected path without panicking.
Bug shape pattern follows feedback_in_process_core_restart_noop — the in-process core boot window is the source — and the dedup gate from sentry-workflow Phase S2 was satisfied (no open or 30-day merged PR mentions OPENHUMAN-TAURI-R5 / -R6).
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
- [x] Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via
diff-cover) meet the gate enforced by.github/workflows/coverage.yml. Runpnpm test:coverageandpnpm test:rustlocally; PRs below 80% on changed lines will not merge. - [x] N/A: behaviour-only demote of a noise bucket — no feature row maps to this in
docs/TEST-COVERAGE-MATRIX.md. - [x] N/A: no feature-matrix row affected by this PR.
- [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
- [x] N/A: this PR does not touch release-cut surfaces — no manual smoke checklist update needed.
- [x] Linked issue closed via
Closes #NNNin the## Relatedsection
Impact
- Sentry noise: ~5k events / window across R5 + R6 stop reaching Sentry. Both still log as breadcrumbs (debug level) so trace correlation survives.
- Runtime: zero —
expected_error_kindis one extra substring check before the existingNetworkUnreachablematcher on the same lowercased buffer. No allocations beyond the existingto_ascii_lowercase. - Platforms: desktop (macOS / Linux / Windows). The errno set covers
EAI_AGAIN/ECONNREFUSEDon all three. - Security / migration: none — observability-only, no schema or API change.
Related
- Closes OPENHUMAN-TAURI-R5
- Closes OPENHUMAN-TAURI-R6
- Follow-up PR(s)/TODOs: none — leak #4 in the family closed by PRs #1719 / #1795 / #1798.
AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
- Key: N/A — Sentry-only triage, no Linear ticket created (per
sentry-workflow.mdPhase S5 fallback). - URL: N/A
Commit & Branch
- Branch:
fix/sentry-loopback-classifier-r5-r6 - Commit SHA:
b61a7053(tip; full chain ingit log upstream/main..HEAD)
Validation Run
- [x] N/A: no frontend changes in this PR —
pnpm --filter openhuman-app format:checknot exercised. - [x] N/A: no TS changes —
pnpm typechecknot exercised. - [x] Focused tests:
cargo test --lib core::observability::tests— 63 passed, 0 failed locally. - [x] Rust fmt/check (if changed):
cargo fmtclean,cargo check --libclean (4 unrelated warnings, all pre-existing onmain). - [x] N/A: no Tauri shell changes —
pnpm rust:checknot exercised againstapp/src-tauri.
Validation Blocked
command:cargo clippy --lib --all-targets -- -D warningserror:93+ pre-existing clippy errors onupstream/main(verified by re-running clippy with the working tree stashed); 0 new from this PR. The-D warningsgate cannot be cleared without an unrelated cleanup pass.impact:none — the PR does not introduce or worsen any clippy diagnostic; observability.rs lines flagged by clippy (2249-2256) are pre-existingDefault::default()field reassignments in test helpers.
Behavior Changes
- Intended behavior change: loopback
Connection refused (os error N)bodies stop being captured as Sentry error events; they demote to adebug!breadcrumb instead. - User-visible effect: none — no log line the user sees changes; only the Sentry dashboard noise drops.
Parity Contract
- Legacy behavior preserved:
NetworkUnreachable,TransientUpstreamHttp, and all other existing buckets keep their current matchers — the new variant is additive and gated on a tighter conjunctive shape. The precedence guard test locks the ladder ordering. - Guard/fallback/dispatch parity checks: existing
is_transient_message_failureat therpc.invoke_methodsite still catches the R6 shape on the fallback path (it already did, via theerror sending requestsubstring) — the new bucket is defense-in-depth at the classifier emit site.
Duplicate / Superseded PR Handling
- Duplicate PR(s): none — sentry-workflow Phase S2 dedup (open + 30-day merged search on
OPENHUMAN-TAURI-R5/-R6andLoopbackUnavailable) returned no matches. - Canonical PR: this PR.
- Resolution: N/A
Summary by CodeRabbit
-
Bug Fixes
- Enhanced error classification for loopback connection failures to provide more accurate diagnostics.
-
Tests
- Extended test coverage for loopback error detection across Linux, WSL, and Windows platforms.
This PR extends the error observability system in Loopback Unavailable Error Classification 🎯 3 (Moderate) | ⏱️ ~20 minutes 🐇 A boot-window hop so light, ✏️ Tip: You can configure your own custom pre-merge checks in the settings.📝 Walkthrough
Walkthrough
src/core/observability.rs with a new expected error classification for core boot-window loopback connection failures (127.0.0.1:<port> / localhost:<port> "Connection refused"), routing them separately from general network problems and reporting them as debug breadcrumbs rather than full error bodies.Changes
Layer / File(s)
Summary
Loopback detection variant and matcher
src/core/observability.rsExpectedErrorKind::LoopbackUnavailable variant is added with documentation for boot-window connection-refused scenarios. The is_loopback_unavailable matcher requires both loopback host+port anchors and OS-specific errno phrases. Classification precedence in expected_error_kind checks loopback detection before NetworkUnreachable, with documentation clarifying the routing.
Loopback error reporting
src/core/observability.rsreport_expected_message adds a LoopbackUnavailable arm that logs a debug breadcrumb with domain/operation/kind tags, excluding raw message/body.
Loopback classification test suite
src/core/observability.rsTests validate R5/R6 loopback connect-refused classification across platform variants, precedence over
NetworkUnreachable, errno handling, rejection of non-transport loopback failures, non-loopback connect-refused routing, conjunctive matcher requirements, and safe report_error_or_expected routing.Estimated code review effort
Possibly related PRs
ExpectedErrorKind and the expected reporting path in the same observability module, adding different classified variants (SessionExpired).src/core/observability.rs, adding new categorization logic and corresponding tests.Suggested labels
workingSuggested reviewers
Poem
Loopback whispers through the night,
Connection refused, but all is well—
A debug breadcrumb's gentle knell. 🌙✨🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title accurately describes the main change: introducing a new error classifier to demote loopback connection refusals to expected/debug breadcrumbs for Sentry, with specific references to the affected R5/R6 issues.
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.
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
Comment @coderabbitai help to get the list of available commands and usage tips.