gh-codeql
gh-codeql copied to clipboard
Better error message for expired/invalid PAT
$ 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.
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.
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 🙂
Interesting...let me play around a bit more. I'm using gh v2.4.0, which is the latest, so it's not that.
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).
🤦🏼 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"
}
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.
That would be nice. I got a message that it expired today, but completely forgot about it.
I'll update the issue title.