The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(credentials): use typed sentinel for offline local session error
Steven Enamakel69a6534012e3
diff --git a/crates/openhuman-core/src/security/credentials/session_support.rs b/crates/openhuman-core/src/security/credentials/session_support.rsindex afe56ee5e7..bae31eb0f5 100644--- a/crates/openhuman-core/src/security/credentials/session_support.rs+++ b/crates/openhuman-core/src/security/credentials/session_support.rs@@ -353,6 +353,12 @@ impl BackendCredential {}}+/// Error [`resolve_backend_credential`] returns for the offline local session.+/// Carries [`BACKEND_UNAVAILABLE_PREFIX`](crate::core::observability::BACKEND_UNAVAILABLE_PREFIX)+/// so it classifies as an expected backend-unavailable error.+pub const LOCAL_SESSION_BACKEND_UNAVAILABLE: &str =+ "BACKEND_UNAVAILABLE: hosted account data is unavailable for the offline local session";+/// Resolve the backend credential for `config`: the API key when one is/// stored, else the live app-session token with exactly the classification/// [`require_live_session_token`] has always applied.@@ -366,8 +372,12 @@ pub fn resolve_backend_credential(config: &Config) -> Result<BackendCredential,}let profile = load_app_session_profile(config)?;match classify_session_token(profile.as_ref(), chrono::Utc::now()) {+ // The offline local session has no TinyHumans account behind it, so a+ // hosted call is unavailable by construction — the typed sentinel lets+ // `report_error_or_expected` demote it instead of paging Sentry on+ // every background usage/announcement probe (Sentry 36649).SessionTokenCheck::Live(token) if is_local_session_token(&token) => {- Err("backend unavailable for offline local session".to_owned())+ Err(LOCAL_SESSION_BACKEND_UNAVAILABLE.to_owned())}SessionTokenCheck::Live(token) => Ok(BackendCredential::Session(token)),SessionTokenCheck::Absent => {diff --git a/crates/openhuman-core/src/security/credentials/session_support_tests.rs b/crates/openhuman-core/src/security/credentials/session_support_tests.rsindex 9c55686bf1..0c84933c75 100644--- a/crates/openhuman-core/src/security/credentials/session_support_tests.rs+++ b/crates/openhuman-core/src/security/credentials/session_support_tests.rs@@ -270,7 +270,16 @@ fn offline_local_token_is_never_a_backend_bearer() {).unwrap();let error = resolve_backend_credential(&config).unwrap_err();- assert_eq!(error, "backend unavailable for offline local session");+ assert_eq!(error, LOCAL_SESSION_BACKEND_UNAVAILABLE);+ assert!(crate::core::observability::is_backend_unavailable_message(+ &error+ ));+ // Regression (Sentry 36649): the local-session refusal must classify as+ // expected, not reach Sentry as an `rpc.invoke_method` error.+ assert!(matches!(+ crate::core::observability::expected_error_kind(&error),+ Some(crate::core::observability::ExpectedErrorKind::BackendUnavailable)+ ));}/// Regression: when both an app-session profile and a stored API key are