Skip to content

Name the saved token's server in device console and shell - #35

Merged
joshk merged 1 commit into
mainfrom
fix/console-token-server-message
Nov 24, 2026
Merged

joshk merged 1 commit into
mainfrom
fix/console-token-server-message

Conversation

@joshk

@joshk joshk commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #33, now that it and #31 are merged.

#33 made nh refuse to send a saved token to a server other than the one it was saved for, and made newAuthedClient return cfg.TokenErr, which names the token's server. device console and device shell open a websocket rather than an API client, and they checked for an empty token themselves. So with a token saved for another server, they said not authenticated: run nh user auth or set NERVES_HUB_TOKEN instead.

Change

  • cmd/helpers.go: the token check is now requireToken(cfg), which newAuthedClient calls.
  • cmd/device_console.go: runDeviceTerminalSession, which both device console and device shell use, calls requireToken too. They now fail with the same saved token is for https://… error as every other command, still before checking for a terminal or dialling.

No other command checks cfg.Token itself. The other direct comparisons in the repo are on API response values.

Tests

  • New TestTerminalSessionsNameTheSavedTokensServer in cmd/token_server_test.go covers console and shell with a token saved for another server. It fails without the change, with the old "not authenticated" error.
  • TestDeviceConsoleRequiresToken and TestDeviceShellRequiresToken still pass. When no token is saved at all, the message is unchanged.
  • go test ./..., go vet ./... and gofmt -l . are clean.

🤖 Generated with Claude Code

device console and device shell checked for an empty token themselves, so
when the saved token was for another server they said "not authenticated"
instead of which server the token is for. Both now share newAuthedClient's
check through requireToken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@joshk
joshk merged commit fc5d928 into main Nov 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant