Repository navigation
fix: name the host a GitHub account lives on - #109
Merged
Merged
Conversation
A login only identifies an account within one host. lich stored the login
alone, and `gh auth token --user <login>` looks a login up on gh's default
host only:
$ gh auth token --user naoexiste
no oauth token found for github.com account naoexiste
So an account authenticated on a GitHub Enterprise instance was offered in
the picker, chosen, not found, and every call fell back to gh's active
account — silently, which is the failure the account picker exists to
prevent. Two hosts holding the same login were the same entry twice.
An account is now "<host>/<login>": the parser keeps the host `gh auth
status` already prints, and the token lookup names it back. A value stored
without a host still resolves on the default host, which is where it was
found, and is rewritten the moment gh says which host that is — otherwise
the picker would list one account twice, once in each form. The host is
spelled out in the picker only when there is more than one in play.
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.
Why
#107 stored a GitHub account as its login alone. A login only identifies an account within one host, and
gh auth token --user <login>looks it up on gh's default host only:So an account authenticated on a GitHub Enterprise instance was listed in the picker, chosen by the user, not found by gh — and
tokenForfell back to the active account without a word. That silent fallback is the exact failure the account picker exists to prevent, and it hit precisely the people most likely to need the picker: anyone whose repositories live on an enterprise host.The same login on two hosts was also a single ambiguous entry.
Worth saying plainly: nothing about the hostname can be inferred. git resolves a host through the ssh config — which is free to point
github.comat an enterprise server — while gh reads the hostname from the remote and talks to that name's API. The two can reach different servers with no sign in the URL, so the host has to be carried, never guessed.What changed
"<host>/<login>". The parser keeps the hostgh auth statusalready prints, andtokenArgsnames it back with--hostname.upgradeAccount), and only when exactly one host claims that login. Otherwise the picker would list one account twice, once in each form. A login gh no longer knows is left alone, so it stays visible and changeable.src/lib/gh-account.ts: it is pure, and in a.tsxthe node-only test gate could not reach it.Test plan
gh:project.GitHubAccountsnow answers["github.com/omartelo", "github.com/marcelo-filho_snk"].marcelo-filho_snk, the form already in my DB) resolves and lists the PRs; the host-qualified value (github.com/marcelo-filho_snk) resolves identically.TestTokenArgspins all three shapes — github.com, an enterprise host, and the host-less legacy form.upgradeAccountcovered for: one host claims the login, two hosts claim it (refuses to guess), gh no longer knows it, already upgraded, empty.go test ./...,gofmt -l .,go vet ./...clean;vitest480 passed,biome check0 errors,tsc --noEmitclean,vite buildok.🤖 Generated with Claude Code