Skip to content

gh auth status -h <enterprise host> passes if host not yet configured #2775

@csaska

Description

@csaska

Describe the bug

For a new user setup, I run gh auth status -h github.example.com to check if a user has setup the CLI tool. I expect this to fail because ~/.config/gh/hosts.yml has no entry for github.example.com. However, it prints no stdout and exits with 0.

Note: gh auth status, which uses github.com by default, will fail if ~/.config/gh/hosts.yml does not exist.

Steps to reproduce the behavior

  1. rm -rf ~/.config/gh
  2. export GITHUB_TOKEN=asdf
  3. gh auth status -h <github-host> # where <github-host> is anything other than 'github.com'

Expected vs actual behavior

Expected:

$ gh auth status -h github.example.com
github.example.com
  X github.example.com: authentication failed
  - The github.example.com token in GITHUB_TOKEN is no longer valid.
$ echo $?
1

Alternate expected behavior:

$ gh auth status -h github.example.com
You are not logged into any GitHub hosts. Run gh auth login to authenticate.
$ echo $?
1

Actual:

$ gh auth status -h github.ibm.com
$ echo $?
0

Note: if I unset GITHUB_TOKEN, gh auth status -h github.example.com outputs "You are not logged into any GitHub hosts. Run gh auth login to authenticate".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issuehelp wantedContributions welcomepriority-3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions