fix(claude): report unauthenticated Claude instances honestly - #8275
fix(claude): report unauthenticated Claude instances honestly#8275filipef101 wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — The PR adds a production Claude authentication probe and changes provider status and login guidance, including platform- and instance-specific behavior. An unresolved issue remains for environment-scoped You can add or adjust custom eligibility rules. Learn more. |
ba55edc to
1796e6b
Compare
A logged-out CLAUDE_CONFIG_DIR still initializes through the Claude Agent
SDK and reports {tokenSource: "none", apiProvider: "firstParty"}, which
the provider snapshot read as "authenticated". That was survivable when
every install had exactly one Claude; a second provider instance points
CLAUDE_CONFIG_DIR at a fresh directory that is logged out by
construction, so the provider list claimed "Authenticated" while every
turn died with "Not logged in - Please run /login".
Restore the `claude auth status` probe that pingdotgg#2277 dropped, run it with
the instance's own environment, and name that instance's config directory
in the login hint so the user logs in the failing instance rather than
the default one.
1796e6b to
bbb3fbe
Compare
|
Thanks — both real, both fixed in the latest push. Auth probe timeout. Correct, and it defeated the PR's own purpose: Login hint quoting. Also right, and it applied to Windows twice over. The path is now shell-quoted, and the command is platform-aware — PowerShell has no inline Two tests added: a config directory containing spaces, and the PowerShell form. 50 passing. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bbb3fbe. Configure here.
| ? `$env:CLAUDE_CONFIG_DIR=${quoted}; claude auth login` | ||
| : `CLAUDE_CONFIG_DIR=${quoted} claude auth login`; | ||
| return `Claude Code is not authenticated for this instance. Run \`${command}\` and try again.`; | ||
| }); |
There was a problem hiding this comment.
Login hint ignores env config dir
Medium Severity
claudeLoginHint only keys off homePath. When homePath is empty, makeClaudeEnvironment still honors an ambient CLAUDE_CONFIG_DIR from the instance or process environment for the auth probe, but the hint falls back to bare claude auth login. That can send the user to the default config dir while the instance stays logged out against the env-scoped one.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit bbb3fbe. Configure here.


Problem
A Claude provider whose CLI is not logged in reports Authenticated in Settings, then fails every turn with
Not logged in · Please run /login.The snapshot derives auth solely from the Agent SDK initialization result. A logged-out config directory still initializes fine and reports
{ tokenSource: "none", apiProvider: "firstParty" }.checkClaudeProviderStatusonly checks whethercapabilitiesis truthy, so that object takes thestatus: "ready"/auth: { status: "authenticated" }branch.This was survivable when every install had one Claude. With provider instances it is not: a second instance points
CLAUDE_CONFIG_DIRat a fresh directory that is logged out by construction, so adding one always produces a provider that claims to be authenticated and cannot run a turn.claude auth statusused to be part of this probe and was dropped in #2277 (feat: Multi-Provider support); this restores that signal.Fix
Ask the CLI, with the instance's own environment:
claude auth statusemits JSON by default;loggedIn: falsemaps toauth: { status: "unauthenticated" }andstatus: "error", matching what Codex and Cursor already report.Claude Code is not authenticated for this instance. Run \CLAUDE_CONFIG_DIR=/Users/you/.claude_work claude auth login` and try again.`No contract change.
auth.status: "unauthenticated"is an existing value that clients already handle — mobile, for instance, already filters unauthenticated providers out of its model picker, so a logged-out instance stops being offered instead of being offered and failing.Tests
Five added to
ProviderRegistry.test.ts: logged-out reporting, the per-instance login hint, non-zero exit still trusted, older CLI keeping the SDK verdict, and account labelling from the CLI.vp test run apps/server/src/provider/Layers/ProviderRegistry.test.ts— 48 passed. Typecheck and lint clean.Claude Opus 5 via Claude Code.
Note
Medium Risk
Changes provider snapshot auth semantics for multi-instance Claude setups; failures in the new probe are designed to fall back, but logged-out instances that previously appeared healthy will now surface as errors.
Overview
Fixes Claude provider health checks that showed Authenticated for logged-out config dirs (common on extra instances with a separate
CLAUDE_CONFIG_DIR) while turns failed with not logged in.checkClaudeProviderStatusnow runsclaude auth statusin the instance environment (withAUTH_PROBE_TIMEOUT_MS). WhenloggedInis false it returnsstatus: errorandauth.status: unauthenticated, with aclaudeLoginHintthat setsCLAUDE_CONFIG_DIRfor that instance—quoted paths and PowerShell vs POSIX syntax on Windows.If the CLI probe is missing, times out, or returns unparseable output, behavior stays on the SDK initialization verdict. When logged in, email and subscription metadata prefer the CLI over the SDK so multiple instances are easier to tell apart. Auth JSON is parsed from stdout even on non-zero exit codes.
Tests in
ProviderRegistry.test.tscover logged-out reporting, per-instance hints, quoting, Windows hints, legacy CLI fallback, CLI account labeling, and non-zero exit trust.Reviewed by Cursor Bugbot for commit bbb3fbe. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Probe
claude auth statusinClaudeProviderand report unauthenticated instances honestlyprobeClaudeAuthStatus, which runsclaude auth statuswith a dedicated timeout, parses stdout viaparseClaudeAuthStatus, and swallows failures by returningundefined.checkClaudeProviderStatusnow returns an explicitunauthenticatederror with a platform-aware login command targeting the instance'sCLAUDE_CONFIG_DIRwhen the CLI reports logged out; authenticated accounts prefer CLI-provided email, subscription, auth method, and API provider, falling back to SDK capabilities.claudeLoginHintandquoteForShellbuild shell-safeCLAUDE_CONFIG_DIR=... claude auth loginhints for POSIX and PowerShell, with correct quoting for paths containing spaces.claude auth status(withAUTH_PROBE_TIMEOUT_MS); if the CLI is missing or unparseable, it falls back to prior SDK-based behavior. Generated login hints reference the per-instance config dir, so users with customCLAUDE_CONFIG_DIRmust run the printed command rather than a bareclaude auth login.Macroscope summarized bbb3fbe.