fix(observability): classify SessionExpired at agent layer (OPENHUMAN-TAURI-26)#1763
fix(observability): classify SessionExpired at agent layer (OPENHUMAN-TAURI-26)#1763CodeGhost21 wants to merge 1 commit into
Conversation
…-TAURI-26)
`agent.run_single` and `web_channel.run_chat_task` call `report_error_or_expected`
*before* the JSON-RPC dispatch boundary sees the error string, so the
session-expired classifier living privately in `core::jsonrpc.rs` never ran
against them. Mid-conversation 401s emitted by the OpenHuman backend
("OpenHuman API error (401 Unauthorized): {…Session expired…}") therefore
escaped as Sentry error events from the agent layer — 15 events on
OPENHUMAN-TAURI-26, all from release 0.53.22 before tinyhumansai#1516's cascade
dampener reduced volume but did not close this code path.
Adds `ExpectedErrorKind::SessionExpired` + a strict shared classifier
`is_session_expired_message` in `core::observability`, anchored on
canonical OpenHuman session phrasing ("session expired", "no backend
session token", "session JWT required", and the `SESSION_EXPIRED`
sentinel) so the demote does not silence BYO-key OpenAI / Anthropic 401s
(those are actionable misconfigurations and must reach Sentry).
The dispatch-site classifier (`core::jsonrpc::is_session_expired_error`)
keeps its existing **looser** "401 + unauthorized" / "invalid token"
match — token cleanup and `DomainEvent::SessionExpired` publish still
fire on every 401 propagated to `invoke_method`, so the auto-cleanup
teardown is unchanged.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds a new ChangesSession-expired error classification
Possibly related PRs
Suggested labels
Suggested reviewers
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
agent.run_singleandweb_channel.run_chat_taskcallreport_error_or_expectedbefore the JSON-RPC dispatch boundary's session-expired filter ever runs, so mid-conversation 401s from the OpenHuman backend ("OpenHuman API error (401 Unauthorized): {…Session expired…}") escaped as Sentry error events from the agent layer — OPENHUMAN-TAURI-26 (15 events on release 0.53.22 before fix(auth): stop 401 cascade after session expiry (OPENHUMAN-TAURI-1T) #1516's cascade dampener reduced volume but did not close the code path).ExpectedErrorKind::SessionExpiredand a strict shared classifieris_session_expired_messageincore::observability. Anchored on canonical OpenHuman session phrasing ("session expired","no backend session token","session JWT required",SESSION_EXPIREDsentinel) so the demote does not silence BYO-key OpenAI / Anthropic 401s — those are actionable misconfigurations and must keep reaching Sentry.core::jsonrpc::is_session_expired_error) stays looser on"401 + unauthorized"/"invalid token"so token cleanup andDomainEvent::SessionExpiredpublish still fire on every 401 propagated toinvoke_method. Auto-cleanup teardown unchanged.Why two classifiers, not one
The dispatch-site predicate needs to be broad enough to clear the local token defensively on any 401 (including a misconfigured BYO-key — clearing stale state is safe). The agent-layer demote must be narrow so a BYO-key 401 still reaches Sentry as an actionable error. Same boundary, different jobs — the docstrings on both helpers call out the relationship explicitly.
Test plan
cargo test --lib observability— 45 pass, new tests cover OPENHUMAN-TAURI-26 wire shape (with caller wrapping), theSESSION_EXPIREDsentinel, "no backend session token" / "session JWT required" pre-flight guards, and explicitly assert BYO-key provider 401s (OpenAI / Anthropic) are not silenced.cargo test --lib jsonrpc— 57 pass, existingis_session_expired_error_*suite still green (the looser dispatch-site classifier is unchanged in behavior).cargo fmt+cargo checkon core (Cargo.toml) and Tauri shell (app/src-tauri/Cargo.toml).Closes
Fixes OPENHUMAN-TAURI-26
Summary by CodeRabbit