fix(rpc/credentials): preserve anyhow context chain in BackendOAuthClient call sites (TAURI-RUST-10)
Summary
- Preserve the
anyhowcontext chain in threeBackendOAuthClientcall sites incredentials/opsso the underlying transport error reaches the rpc dispatcher. - Drops Sentry TAURI-RUST-10 ("GET /auth/me", 409 events / 17 users / since 2026-05-19), which was an opaque transient-network noise group caused by
e.to_string()collapsing the chain. - Adds defense-in-depth
before_sendfilteris_auth_get_me_opaque_transport_eventso any future regression that re-emits the same opaque shape stays off Sentry.
Problem
Sentry TAURI-RUST-10 shows 409 events / 17 users since v0.54.0 with:
message/title: literallyGET /auth/me- tags:
domain=rpc,operation=invoke_method,method=openhuman.auth_get_me,elapsed_ms≈5003 - No exception, no stack, no status code, no underlying transport text.
Trace:
- Frontend calls RPC
openhuman.auth_get_me→src/openhuman/credentials/ops.rs:451. auth_get_mecallsBackendOAuthClient::fetch_current_user(src/api/rest.rs:402), which doesclient.get(url).send().await.context("GET /auth/me")?. This wraps the underlyingreqwest::Error(operation timed out,connection reset,tls handshake eof, etc.) under the top context"GET /auth/me".- Back in
auth_get_me:.map_err(|e| e.to_string())?.anyhow::Error::to_string()renders only the top-most context — the underlying transport error is dropped. The string handed up the stack becomes exactly"GET /auth/me". - The rpc dispatcher (
src/core/jsonrpc.rs:39) runs its classifier ladder.is_transient_message_failure("GET /auth/me")returns false becauseTRANSIENT_TRANSPORT_PHRASES("timeout","connection reset","tls handshake eof","error sending request") were stripped in step 3. - The classifier misses →
report_error_or_expected("GET /auth/me", "rpc", "invoke_method", …)→sentry::capture_message("GET /auth/me", Error). Group fingerprint stabilizes on the bare literal → every transient network blip folds into one opaque high-traffic issue.
elapsed_ms = 5003 + the 17-user / 26-day spread are consistent with episodic transient network failures (launch / resume / sleep-wake), not a real backend regression. The reqwest client has 15s connect / 120s total timeouts, so the ~5s timing is a fast network failure (DNS, refused, transient TLS) — exactly the class is_transient_message_failure is built to demote.
Same .map_err(|e| e.to_string()) anti-pattern existed in sibling endpoints (consume_login_token, auth_create_channel_link_token) — fixing all three preemptively.
Solution
Primary fix — preserve the error chain at the three sibling call sites in src/openhuman/credentials/ops.rs:
- .map_err(|e| e.to_string())?;
+ .map_err(|e| format!("{e:#}"))?;
format!("{e:#}") is anyhow's alternate Display, which walks the full context chain. After the fix, a transient timeout surfaces as e.g. "GET /auth/me: error sending request for url (https://api.tinyhumans.ai/auth/me): operation timed out". The existing skip-path at core::jsonrpc::rpc_handler (is_transient_message_failure → tracing::warn!, no Sentry) now matches and demotes to warn. Genuine non-transient backend errors still page, but with usable text instead of just the path.
Defense in depth — new classifier in src/core/observability.rs:
pub fn is_auth_get_me_opaque_transport_event(event: &sentry::protocol::Event<'_>) -> bool
Strictly matches the TAURI-RUST-10 fingerprint:
- tag
domain == "rpc" - tag
operation == "invoke_method" - tag
method == "openhuman.auth_get_me" event.message(or last exceptionvalue) trims to exactly"GET /auth/me"(strict equality — chain-bearing messages still page).
Wired into the before_send chain in src/main.rs alongside is_session_expired_event / is_max_iterations_event. Pattern + docstring shape mirrors those siblings so the three layers can't drift.
Tests — 7 new unit tests in core::observability::tests:
- Drops bare
"GET /auth/me"(TAURI-RUST-10 shape). - Tolerates surrounding whitespace.
- Keeps the full-chain shape (
"GET /auth/me: error sending request …") — must reach Sentry. - Strict-scoped to method=
openhuman.auth_get_me(sibling methodsconsume_login_token, etc. surface). - Strict-scoped to domain=
rpc+ operation=invoke_method. - Matches the
sentry-tracingexception-value path. - Substring matches do NOT trigger (only strict equality).
Submission Checklist
If a section does not apply to this change, mark the item as
N/Awith a one-line reason. Do not delete items.
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
- [x] Diff coverage ≥ 80% — every changed line in the new filter is exercised by the 7 new unit tests; the three
format!("{e:#}")lines are the existing tested error paths and the test surface covers the resulting body shapes. - [x] Coverage matrix updated — N/A: pure noise-classifier addition, no new feature row;
auth_get_mebehavior is unchanged for callers. - [x] All affected feature IDs from the matrix are listed in the PR description under
## Related— N/A: behaviour-only change to error string formatting + Sentry classifier. - [x] No new external network dependencies introduced (mock backend used per Testing Strategy)
- [x] Manual smoke checklist updated if this touches release-cut surfaces (
docs/RELEASE-MANUAL-SMOKE.md) — N/A: no release-cut UI surface touched. - [x] Linked issue closed via
Closes #NNNin the## Relatedsection — N/A: tracked only in Sentry (TAURI-RUST-10), no GitHub issue.
Impact
- Runtime: desktop only. The three changed call sites are the desktop core's backend OAuth client.
- Behavior change: error strings returned by
auth_get_me/consume_login_token/auth_create_channel_link_tokennow include the underlying transport context when the request fails — strictly more informative, never less. The frontend already surfaces these viacallCoreCommandfailure paths and treats them as opaque strings. - Performance: zero (single Display invocation, same path).
- Security: no new PII risk. The reqwest errors include URLs, which are already in our scrub list (
scrub_secrets/sanitize_api_error); the rpc dispatcher's existingtracing::warn!skip-path already redacts before logging. - Sentry volume: drops ~400 events / month on TAURI-RUST-10. Genuine
auth_get_mefailures still report with actionable text.
Related
- Closes: N/A (Sentry-tracked: TAURI-RUST-10)
- Follow-up PR(s)/TODOs: same
e.to_string()anti-pattern likely exists at other anyhow boundaries in the credentials/integrations layer — sweep candidate, out of scope here.
AI Authored PR Metadata (required for Codex/Linear PRs)
Keep this section for AI-authored PRs. For human-only PRs, mark each field
N/A.
Linear Issue
- Key: N/A
- URL: N/A (Sentry TAURI-RUST-10: https://sentry.tinyhumans.ai/organizations/tinyhumans/issues/98/)
Commit & Branch
- Branch:
fix/sentry-tauri-rust-10-auth-get-me - Commit SHA:
58c4aa9e649f5b25864c5a2ab0698284daf9f709
Validation Run
- [x]
pnpm --filter openhuman-app format:check— N/A: Rust-only change, no TS/TSX touched. - [x]
pnpm typecheck— N/A: Rust-only change. - [x] Focused tests:
cargo test --lib observability::tests::auth_get_me→ 7 passed;cargo test --lib credentials::ops→ 37 passed;cargo test --lib observability::→ 164 passed. - [x] Rust fmt/check (if changed):
cargo fmt --checkclean;cargo check --bin openhuman-coreclean (warnings only, all pre-existing and unrelated). - [x] Tauri fmt/check (if changed): N/A: no tauri shell code touched.
Validation Blocked
command:N/Aerror:N/Aimpact:N/A
Behavior Changes
- Intended behavior change:
auth_get_me(and two sibling RPCs) now propagate the full anyhow context chain on error, instead of collapsing to the top-most context string only. - User-visible effect: when a backend auth call fails transiently, the user sees the same UI-level "couldn't reach backend" path, but the chain is no longer reported to Sentry as noise. On genuine non-transient errors, the actionable text is preserved (better debuggability).
Parity Contract
- Legacy behavior preserved: success path is byte-identical. Error-path callers receive a strictly-longer error string (anyhow chain instead of top context). All call sites treat the error as an opaque
Stringand either log or surface to UI — no callers parse the bytes for specific text. - Guard/fallback/dispatch parity checks: the new
before_sendfilter strictly matches the previously-leaked TAURI-RUST-10 shape only (bare path, no chain). Post-fix shape with the chain still routes through the existingis_transient_message_failureskip path atrpc_handler, unchanged. Real backend errors continue to page.
Duplicate / Superseded PR Handling
- Duplicate PR(s): N/A — verified no open PR / local branch covers TAURI-RUST-10 /
auth_get_me. - Canonical PR: this one.
- Resolution: N/A.
Summary by CodeRabbit
- Bug Fixes
- Enhanced authentication-related error messages to include full context chains for clearer diagnosis when requests fail.
- Monitoring
- Reduced Sentry noise by filtering out specific deterministic transport-related failures for the
auth_get_meRPC, while preserving other events and errors for visibility.
- Reduced Sentry noise by filtering out specific deterministic transport-related failures for the
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b142b36a-e707-466f-a15f-a93f95b649da
📥 Commits
Reviewing files that changed from the base of the PR and between 58c4aa9e649f5b25864c5a2ab0698284daf9f709 and f9fe41bfdeec94cf7e2a4176d5eb574ca12e8897.
📒 Files selected for processing (1)
src/core/observability.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- src/core/observability.rs
📝 Walkthrough
Walkthrough
Three auth credential ops (auth_get_me, consume_login_token, auth_create_channel_link_token) now emit full anyhow error chains using {e:#}. A new Sentry before_send classifier, is_auth_get_me_opaque_transport_event, suppresses events tagged as openhuman.auth_get_me RPC calls whose body is exactly the bare string GET /auth/me; the hook is wired in main.rs.
Changes
Auth error enrichment and Sentry suppression filter
| Layer / File(s) | Summary |
|---|---|
Full anyhow error chains in auth credential ops src/openhuman/credentials/ops.rs |
auth_get_me, consume_login_token, and auth_create_channel_link_token now format request failures with {e:#} to include the full anyhow context chain instead of only the top-level error string. |
Sentry classifier, tests, and before_send wiring src/core/observability.rs, src/main.rs |
is_auth_get_me_opaque_transport_event checks domain=rpc, operation=invoke_method, method=openhuman.auth_get_me tags and drops events whose body is exactly the trimmed string GET /auth/me (from event.message or the last exception's value). Tests cover bare-body suppression, whitespace tolerance, full-chain non-suppression, wrong-tag passthrough, and exception-value path. The before_send hook in main.rs calls the classifier and returns None with a debug log when matched. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
🐇 Hop, hop — a noisy event sneaks through, But the filter sniffs it: "bare GET /auth/me, shoo!" Full chains now blossom where bare strings once hid, The Sentry inbox thanks this tiny rabbit kid. No opaque ghost shall ring the alarm bell — hooray!
🚥 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 accurately captures the primary fix: preserving anyhow context chains in BackendOAuthClient call sites, referencing the specific ticket TAURI-RUST-10. |
| 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.