fix(desktop): only treat real 401/403 as OAuth session expiry - #59238
Closed
33hodl wants to merge 1 commit into
Closed
fix(desktop): only treat real 401/403 as OAuth session expiry#5923833hodl wants to merge 1 commit into
33hodl wants to merge 1 commit into
Conversation
Previously, any error during ws-ticket minting (including timeouts and 5xx responses) was turned into a 'session expired, sign in again' error. This caused false-positive 'remote gateway session has expired' messages when the gateway was reachable but slow or temporarily unhealthy. - Add isGatewayAuthFailure / isOauthSessionAuthFailure helpers that only match statusCode 401/403 or equivalent message patterns. - Non-auth failures now propagate unchanged instead of being wrapped as GatewayReauthRequiredError. - Updated tests to cover both the auth-failure path and the transport- failure path. This directly addresses the misclassification seen in Desktop boot logs where 'Cached remote Hermes backend failed liveness probe' was followed by a spurious reauth prompt. Fixes the root cause of many false 'sign in again' prompts on remote OAuth gateways.
Contributor
|
Thanks for isolating the false-positive reauthentication path and adding focused tests. Problems
Suggested changes
Automated hermes-sweeper review. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Previously, any failure during
POST /api/auth/ws-ticket(including timeouts, 5xx, and transient network errors) was wrapped as aGatewayReauthRequiredErrorand surfaced to the user as:This caused false-positive "session expired" messages on healthy but occasionally slow remote OAuth gateways.
Root cause
resolveGatewayWsUrl,resolveTestWsUrl, andbuildRemoteConnectiontreated every ticket-mint error as an auth failure, without distinguishing real auth failures (401/403) from transport/runtime failures (timeouts,5xx, connection resets).Fix
Introduced two small helpers:
isGatewayAuthFailure(shared)isOauthSessionAuthFailure(electron)These only match actual auth failures (
statusCode401/403or equivalent message patterns). Non-auth failures now propagate unchanged.Verification
node --check apps/desktop/electron/main.cjsnode --check apps/desktop/electron/connection-config.cjsnode --test apps/desktop/electron/connection-config.test.cjs→ 52 passedcd apps/desktop && npx vitest run src/lib/gateway-ws-url.test.ts→ 13 passedImpact