test(observability): pin SESSION_EXPIRED wire-shape regression tests (#SG)#2188
Conversation
…wire shape OPENHUMAN-TAURI-SG (33 events, escalating, release 0.53.43) was a pre-tinyhumansai#1763 leak of `providers::openhuman_backend::resolve_bearer`'s SESSION_EXPIRED sentinel through `agent.run_single`. PR tinyhumansai#1763 (1fb0bef) wired the `SessionExpired` arm and the classifier now matches verbatim. Add a single-case test that pins the exact byte string lifted from the Sentry-event payload so a future tweak to `is_session_expired_message` (or its callers) cannot regress this specific wire form without a red test. Related: OPENHUMAN-TAURI-SG
…47,266)
`providers::factory::verify_session_active` emits two more SESSION_EXPIRED
bail variants alongside the run_single sentinel that anchored SG:
- "SESSION_EXPIRED: backend session not active — sign in to use custom providers"
(scheduler_gate signed-out fast-path)
- "SESSION_EXPIRED: no backend session — sign in to use OpenHuman"
(empty auth-profile JWT pre-flight)
All three currently classify via the `msg.contains("SESSION_EXPIRED")`
branch in `is_session_expired_message`. Pin both sibling strings with
their own test so a future matcher tweak (e.g. moving from `contains`
to a stricter prefix/suffix match) is caught for the whole family, not
just the SG instance — preventing leak #3 / #4 down the line.
Related: OPENHUMAN-TAURI-SG
|
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 (1)
📝 WalkthroughWalkthroughTwo regression unit tests were added to ChangesSession Expired Classification Tests
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
OPENHUMAN-TAURI-SG's verbatim wire shape and the two sibling bail variants inproviders::factory::verify_session_active.Problem
OPENHUMAN-TAURI-SG(33 events, escalating, all on release0.53.43+2b64ea8…) leaked theSESSION_EXPIRED: backend session not active — sign in to resume LLM worksentinel — raised atsrc/openhuman/inference/provider/openhuman_backend.rs:55(resolve_bearer) — throughagent.run_single(src/openhuman/agent/harness/session/runtime.rs:528) before PR #1763 wired theExpectedErrorKind::SessionExpiredarm insrc/core/observability.rs. Lane C's KICKOFF Step 1 diagnostic test confirmed the post-#1763 classifier already matches the SG byte string verbatim; the existingclassifies_session_expired_messagestest (src/core/observability.rs:1594) covers the same string but does not anchor it to the Sentry-event payload as a pinned regression case. Lane C Step 2A grep acrossagent/,cron/,scheduler_gate/,inference/found no directreport_error!/capture_messagebypass — everySESSION_EXPIREDemitter routes throughreport_error_or_expectedonmain. The 33 events are pre-fix-release noise on0.53.43(does not contain1fb0bef5) and will phase out as staging/production binaries roll pastv0.53.48-staging+(which does contain the fix).Two sibling sentinel sites at
src/openhuman/inference/provider/factory.rs:247and:266(verify_session_active) emit related but distinctSESSION_EXPIRED:messages. They share theis_session_expired_messagemsg.contains("SESSION_EXPIRED")branch with the SG sentinel — a single matcher tweak (e.g. tightening fromcontainsto a prefix/suffix anchor) would silently re-leak all three. None of the three sibling strings had its own pinned test before this PR.Solution
Two new tests in
src/core/observability::tests, kept tight and family-scoped:session_expired_sg_wire_shape_matches— single-case test asserting the exact byte string lifted from theOPENHUMAN-TAURI-SGSentry-event payload classifies asExpectedErrorKind::SessionExpired. Anchored to the Sentry payload so a future matcher tweak can't regress this specific wire form without a red test (and an explicit message linking the regression cost: "re-leaks 33+ events/cycle to Sentry").session_expired_sibling_family_factory_strings_match— pins bothfactory.rs:247andfactory.rs:266variants. Same arm, different suffix bytes — any matcher narrowing that catches one but misses another would surface here.No change to
is_session_expired_message,expected_error_kind, or any caller. Scope deliberately narrow per KICKOFF: do not generalize the matcher beyond what is needed (per #1719 CR — broadening risks BYO-key 401 false-positives).Submission Checklist
#[test]fns pinning three distinct verbatim wire strings; existingdoes_not_classify_byo_key_provider_401_as_session_expiredanddoes_not_classify_unrelated_messages_as_session_expiredcover the negative path.+48lines, all inside#[cfg(test)] mod tests); diff-cover treats new test code as covered-by-itself.## Related— see prior item; no matrix delta.Closes #NNNin the## Relatedsection — Sentry-only PR (no GH issue), mirrors PRs fix(observability): drop 401 session-expired Sentry noise (#25, #1Q, #27, #1G) #1719 / fix(observability): close 3 transient-failure leak paths in Sentry classifier (#1608) #1798 / fix(observability): demote composio validation noise to expected user-state (#3R #3S #33 #34 #97) #1795. Sentry ID closed viaCloses OPENHUMAN-TAURI-SGunder## Related.Impact
#[cfg(test)]only, no binary diff inopenhuman-coreorapp/src-tauri.clippy::useless_vec,clippy::field_reassign_with_default,clippy::duplicate_mod) is unrelated to this PR and predates the branch tip — flagged onupstream/maindirectly.Related
Closes OPENHUMAN-TAURI-SG
Sentry-Issue: OPENHUMAN-TAURI-SG
Context PRs:
SessionExpiredarm at agent layer (the actual fix; this PR adds tests around it)AI Authored PR Metadata (required for Codex/Linear PRs)
Linear Issue
Commit & Branch
fix/sentry-session-expired-leak-sg5aed9756(head)Validation Run
pnpm --filter openhuman-app format:check— Rust-only change, noapp/files touched.pnpm typecheck— Rust-only change.cargo test --lib core::observability::tests(57 passed, 0 failed) andcargo test --lib core::observability::tests::session_expired(both new tests green).cargo fmt --checkclean;cargo checkclean.app/src-tauri/change.Validation Blocked
command:cargo clippy --lib --tests -- -D warningserror:501 pre-existing clippy errors across unrelated files (e.g.src/openhuman/tokenjuice/text/process.rsclippy::useless_vec,src/openhuman/inference/provider/compatible_dump.rsclippy::duplicate_mod,src/core/observability.rs:2193,2199clippy::field_reassign_with_default). None introduced by this branch; all reproduce onupstream/main(7741c58).impact:none — added test code is clippy-clean.Behavior Changes
Parity Contract
None, unrelated 401 / 500 still classifiedNone).Summary by CodeRabbit