fix: show distinct gateway-auth-rejected message and stop misrouting 'token' errors (#239) - #250
Merged
outsourc-e merged 1 commit intoMay 3, 2026
Conversation
…nd stop misrouting benign 'token' errors Two related bugs in src/lib/connection-errors.ts caused the wrong UI message when the gateway refused a device's auth token (issue outsourc-e#239, 'Hermes Agent rejected the connection token'). 1) getConnectionErrorMessage had unreachable code: the 'gateway_auth_rejected' case fell through to a duplicated 'clawsuite_auth_required' label, which is already handled above. That meant gateway-auth rejection always returned the ClawSuite 'Claude Login Required / Enter your password' UI, which is wrong when the actual problem is the gateway refusing the device token. Fix: give 'gateway_auth_rejected' its own message that points the user at re-pairing the device or checking the gateway token, not at typing a password. 2) classifyConnectionError matched on lower.includes('token'), which misrouted benign network errors like 'failed to fetch token from /api/foo' to gateway_auth_rejected. Fix: require 'token' to co-occur with an auth-failure marker (unauthorized / forbidden / rejected / invalid / expired / 401 / 403 / etc.) before classifying as auth-rejected. Bare 'token' strings now fall through to the appropriate network/unknown bucket. Adds full unit-test coverage for the classifier and the message table, including regression tests for both bugs. Fixes outsourc-e#239
JohnGuidry
pushed a commit
to JohnGuidry/hermes-workspace
that referenced
this pull request
May 26, 2026
…nd stop misrouting benign 'token' errors (outsourc-e#250) Two related bugs in src/lib/connection-errors.ts caused the wrong UI message when the gateway refused a device's auth token (issue outsourc-e#239, 'Hermes Agent rejected the connection token'). 1) getConnectionErrorMessage had unreachable code: the 'gateway_auth_rejected' case fell through to a duplicated 'clawsuite_auth_required' label, which is already handled above. That meant gateway-auth rejection always returned the ClawSuite 'Claude Login Required / Enter your password' UI, which is wrong when the actual problem is the gateway refusing the device token. Fix: give 'gateway_auth_rejected' its own message that points the user at re-pairing the device or checking the gateway token, not at typing a password. 2) classifyConnectionError matched on lower.includes('token'), which misrouted benign network errors like 'failed to fetch token from /api/foo' to gateway_auth_rejected. Fix: require 'token' to co-occur with an auth-failure marker (unauthorized / forbidden / rejected / invalid / expired / 401 / 403 / etc.) before classifying as auth-rejected. Bare 'token' strings now fall through to the appropriate network/unknown bucket. Adds full unit-test coverage for the classifier and the message table, including regression tests for both bugs. Fixes outsourc-e#239
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
Fixes the wrong UI message when the gateway refuses a device's auth token (the user-visible string is "Hermes Agent rejected the connection token").
Two related bugs in
src/lib/connection-errors.ts:1. Dead-code
casefallthroughgetConnectionErrorMessagehad a duplicatecase 'clawsuite_auth_required':label sitting betweencase 'gateway_auth_rejected':and its body:Because
clawsuite_auth_requiredis handled by the previous arm, everygateway_auth_rejectedended up rendering the ClawSuite "Login Required / Enter your password" UI — which is the wrong remedy when the actual problem is the gateway refusing the device token. (No password to enter — you need to re-pair / fix the gateway token.)2. Over-broad
'token'heuristic inclassifyConnectionErrorAny error whose message merely contained the substring
token(including benign network errors likefailed to fetch token from /api/foo,cancellation token, etc.) got classified asgateway_auth_rejected, which compounded bug #1 by sending the user to a "log in again" prompt.Fix
gateway_auth_rejectedits own dedicated message that tells the user the gateway refused the device's token and points them at re-pairing / checking the gateway token (not at typing a password).'token'is now a hit only when paired with an auth-failure marker (unauthorized,forbidden,rejected,invalid,expired,missing,401,403, …). Bare'token'strings fall through to the network/unknown bucket as before.The two fixes work together — the heuristic stops over-matching, and even when
gateway_auth_rejecteddoes legitimately fire, the user now sees an accurate message.Tests
Added
src/lib/connection-errors.test.tswith 17 specs covering:"Hermes Agent rejected the connection token"must classify togateway_auth_rejected, andgetConnectionErrorMessage('gateway_auth_rejected')must return a different title/description thanclawsuite_auth_requiredand must not tell the user to enter a password."failed to fetch token from /api/foo"must classify togateway_unreachable, notgateway_auth_rejected.ConnectionErrorKindreturns a non-empty title and description.Full suite before fix:
19 failed | 172 passed. After fix:19 failed | 189 passed— same pre-existing failures (inmarkdown.test,chat-message-list.test,-models.test,-servers.test), no regressions, +17 new passing tests.Fixes #239