Windows: report clawde auth success correctly; skip re-auth when already logged in - #17
Merged
Merged
Conversation
`clawde auth` reported "Authentication failed" on a SUCCESSFUL Windows login: ccproxy authenticated, saved the token, then crashed printing its Unicode success glyph under a legacy code page (cp1252), exiting non-zero - and Cmd-Auth judged success purely by exit code. A first-run config-init step also crashed because it redirected the child's stdout and stderr to the SAME file. - Force PYTHONIOENCODING=utf-8 / PYTHONUTF8=1 on every ccproxy child (Cmd-Auth and Invoke-CCProxyWithTimeout) so the success message prints and the exit code becomes trustworthy again. This is the load-bearing fix. - Skip login entirely when already authenticated: Cmd-Auth now runs `auth status claude` first and returns "[OK] Already authenticated" on valid credentials, instead of pushing the user through a needless OAuth round-trip. - Invoke-CCProxyWithTimeout: separate stdout/stderr temp files (Start-Process rejects the same file for both), combine both on return, guard $p.Kill() against a null process, and on a launch failure return a real error + exit 1 instead of a false "timed out". - Test-AuthSucceeded: treat login as successful when exit code is 0 OR the login-emitted "Authentication successful" appears, so a cosmetic non-zero exit cannot mask a real login. (Only the login string is matched; the "valid credentials" phrasing belongs to `auth status`, used by the pre-check.) Verified live on Windows: the affected account was already authenticated (valid credentials + refresh token in the keyring) and the proxy serves healthily - the new pre-check correctly detects this and reports "already authenticated". Closes #16 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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 #16: on Windows,
clawde authreported "Authentication failed" even when the Claude login succeeded. The auth completes and the token is saved, but the proxy crashes printing its success message under Windows' legacy console encoding, and clawde judged the outcome purely by the crashed process's exit code. A first-run config step also crashed on a redirect conflict.What changed (all in
cli/clawde.ps1)PYTHONIOENCODING/PYTHONUTF8) so it can print its non-ASCII success message without crashing on a legacy code page. This is the load-bearing fix — it makes the exit code trustworthy again.clawde authnow checks status first and reports "[OK] Already authenticated" instead of pushing a needless re-login.clawde auth --force(or--relogin) still forces a fresh login for account-switching or replacing revoked credentials; the skip message names that escape and the help text reflects it.Verified live on Windows
The affected account was in fact already authenticated (valid credentials + refresh token in the keyring) and the proxy serves healthily — the failure was purely in reporting. The new already-authenticated pre-check was confirmed to fire correctly on the real machine.
Reviewer note
The
.ps1blob is LF vs. the base's stale CRLF, so the plain diff is inflated — review withgit diff --ignore-cr-at-eol(real change ~68 lines).Note
Defect 1 is an upstream proxy bug (it shouldn't crash printing its own success message); clawde neutralizes it by setting the child's encoding. Pre-existing on Windows, not a recent regression.
Closes #16
🤖 Generated with Claude Code