gh-codeql icon indicating copy to clipboard operation
gh-codeql copied to clipboard

Better error message for expired/invalid PAT

Open aeisenberg opened this issue 3 years ago • 7 comments

$ gh codeql list-versions
expected an object but got: string ("https://docs.github.com/rest")

I haven't investigated, but perhaps this is making an invalid API request.


EDIT: The reason for the error was an expired PAT. Leaving this issue open so we can provide a better error message in this case.

aeisenberg avatar Jan 25 '22 18:01 aeisenberg

Similar error with download.

$ gh codeql  download 2.7.5
expected an object but got: string ("https://docs.github.com/rest")
ERROR: Version '2.7.5' not found.

aeisenberg avatar Jan 25 '22 18:01 aeisenberg

Hmm, everything is working fine for me and I can't seem to reproduce this locally. There must be something in your local environment that is different to mine (perhaps a Mac version of one of the utilities we are using that is doing something different from the Linux one?). I'd be happy to debug this together if you want to put a call in my calendar whenever suits you 🙂

edoardopirovano avatar Jan 25 '22 18:01 edoardopirovano

Interesting...let me play around a bit more. I'm using gh v2.4.0, which is the latest, so it's not that.

aeisenberg avatar Jan 25 '22 18:01 aeisenberg

Incidentally, gh codeql download 2.7.5 does fail for me but with a different error (it wants gh codeql download v2.7.5 because the release tags have a v before them. I added some logic that automatically adds it when it's missing in set-version in https://github.com/github/gh-codeql/pull/7 but apparently that logic isn't being used for download).

edoardopirovano avatar Jan 25 '22 18:01 edoardopirovano

🤦🏼 Looks like my PAT expired:

$ gh api repos/github/codeql-cli-binaries/releases
gh: Bad credentials (HTTP 401)
{
  "message": "Bad credentials",
  "documentation_url": "https://docs.github.com/rest"
}

aeisenberg avatar Jan 25 '22 18:01 aeisenberg

Aha, that would make sense. Still we could definitely recognise a 401 error and give the user a more informative error about renewing their PAT.

edoardopirovano avatar Jan 25 '22 18:01 edoardopirovano

That would be nice. I got a message that it expired today, but completely forgot about it.

I'll update the issue title.

aeisenberg avatar Jan 25 '22 18:01 aeisenberg