GitHub source control shows "Not authenticated" when `gh` is outdated (missing `auth status --json`) #3806
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Install
gholder than 2.81.0 (e.g.2.74.2) on the machine running T3 Code. - Run
gh auth login, and confirmgh auth statusshows you logged in. - Open Settings → Source Control, then click Rescan.
Expected behavior#
GitHub is reported as authenticated, since gh auth status confirms the user is signed in.
Actual behavior#
GitHub shows "Not authenticated" and Rescan never clears it, even though the user is fully signed in. Because the message tells you to sign in, users run gh auth login over and over — which never helps, since the real problem is the CLI version, not the login.
Root cause: the server detects auth by running gh auth status --json hosts and parsing the JSON:
apps/server/src/sourceControl/GitHubSourceControlProvider.ts:91—authArgs: ["auth", "status", "--json", "hosts"]- The
--jsonflag was only added togh auth statusin gh v2.81.0 (cli/cli#11544, merged 2025-09-25).
On older gh, the command fails with unknown flag: --json (exit 1), so parseGitHubAuthStatus returns { parsed: false }, and parseGitHubAuth falls into the exitCode !== 0 branch (GitHubSourceControlProvider.ts:70) → "unauthenticated". gh --version is never consulted, and the raw error is hidden behind a generic badge — so the UI conflates "your CLI is too old" with "you're logged out," which have opposite fixes.
Impact#
Major degradation or frequent failure
Version or commit#
Environment#
gh 2.74.2 (reproduces on any gh < 2.81.0).
Logs or stack traces#
$ gh auth status --json hosts
unknown flag: --json
Screenshots, recordings, or supporting files#
Before / after:
Workaround#
Upgrade gh to v2.81.0 or newer.
Proposed fix (implemented in a draft PR): distinguish an outdated source-control auth status from unauthenticated — when gh rejects --json (or the parsed gh --version is < 2.81.0), report outdated with an "Outdated CLI" badge instead of "Not authenticated".
the flag is almost a year old soon so i think it's fair to require users keeping their deps somewhat up to date
juliusmarminge closed this
Sign in to join this conversation.
Independently reproduced on Linux with
gh 2.45.0(Ubuntu package), fully logged in — T3 reportedauth: { status: "unauthenticated", detail: "unknown flag: --json" }whilegh auth statusshowed the account signed in.Opened #3943 with a fix: an opt-in
authFallbackArgson the CLI discovery spec, retried only when the primary probe exits non-zero without resolving an account, plus a text parser forgh auth statusoutput (handles both the currentaccount <login>and olderas <login>phrasings). Verified end-to-end against a CLI that rejects--json: status flips fromunauthenticatedtoauthenticated.