Skip to content

Connection timeout is incorrectly reported as invalid token #8293

Closed

Description

@tekumara

Describe the bug

Connect timeout is incorrectly reported as invalid token

Steps to reproduce the behavior

  1. Authenticate to a GHE host (eg: ghe.mycorp.org) on the VPN, then disconnect from the VPN
  2. Note that the connection now times out, eg:
    ❯ curl --connect-timeout 5 https://ghe.mycorp.org
    curl: (28) Failed to connect to ghe.mycorp.org port 443 after 2005 ms: Timeout was reached
    
  3. Check auth status, eg:
    ❯ gh auth status -h ghe.mycorp.org
    ghe.mycorp.org
      X ghe.mycorp.org: authentication failed
      - The ghe.mycorp.org token in keyring is invalid.
      - To re-authenticate, run: gh auth login -h ghe.mycorp.org
      - To forget about this host, run: gh auth logout -h ghe.mycorp.org    
    

Expected vs actual behavior

Connection timeouts should be reported as connection timeout rather than an invalid token. An invalid token suggests reauthentication is required, when the solution is to resolve the connection timeout (eg: by connecting to the VPN).

Logs

❯ gh --version
gh version 2.38.0 (2023-11-01)
https://github.com/cli/cli/releases/tag/v2.38.0

Activity

  1. added
    priority-3Affects a small number of users or is largely cosmetic
    gh-authrelating to the gh auth command
    and removed on Nov 6, 2023
  2. samcoe commented on Nov 6, 2023

    @samcoe
    Contributor

    @tekumara Thanks for writing in. You are correct that when we encounter an http error gh auth status we automatically assume it is in invalid token even in other cases such as network timeouts. We can definitely improve the messaging in this case to indicate to the user that we were unable to make a connection rather than the current invalid token message. Here is where we currently output the invalid token message and where we should start doing some validation about the type of error that occurred.

  3. mateusmarquezini commented on Nov 14, 2023

    @mateusmarquezini
    Contributor

    Hi there @samcoe, is someone already looking into this? I'd like to give it a try. Thanks!

  4. samcoe commented on Nov 15, 2023

    @samcoe
    Contributor

    @mateusmarquezini I do not believe there are any open PRs for this bug, go for it 👍

  5. mateusmarquezini commented on Nov 15, 2023

    @mateusmarquezini
    Contributor

    Awesome, thanks @samcoe !

  6. tal66 commented on Nov 15, 2023

    @tal66
    Contributor

    sorry mateusmarquezini, just now seen your comment after already submiting a pr (i had the tab open from a day before).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-authrelating to the gh auth commandhelp 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