GitHub: An invalid PAT should surface a user friendly error
- Dominant language
- C#
- Stars
- 478
- Forks
- 146
- Avg merge
- 7d 21h
- Merged PRs (30d)
- 2
Description
## Description
If a GH PAT is not valid, an actionable user friendly error should be surfaced.
## Reproduction Steps
export ADO_PAT="VALID_PAT"
export GH_PAT="1234"
`gh ado2gh migrate-repo --ado-org "valet-testing" --ado-team-project "build-playground" --ado-repo "forecast-regression-test" --github-org "import-testing" --github-repo "build-playground-forecast-regression-test"`
Will output the following:
```
[2023-10-12 10:29:39] [INFO] You are running the latest version of the ado2gh CLI [v1.2.0]
[2023-10-12 10:29:39] [INFO] ADO ORG: valet-testing
[2023-10-12 10:29:39] [INFO] ADO TEAM PROJECT: build-playground
[2023-10-12 10:29:39] [INFO] ADO REPO: forecast-regression-test
[2023-10-12 10:29:39] [INFO] GITHUB ORG: import-testing
[2023-10-12 10:29:39] [INFO] GITHUB REPO: build-playground-forecast-regression-test
[2023-10-12 10:29:39] [INFO] Migrating Repo...
[2023-10-12 10:29:40] [ERROR] Failed to lookup the Organization ID for organization 'import-testing'
```
A `401` error was surfaced in the logs:
```
2023-10-12 10:29:05] [ERROR] OctoshiftCLI.OctoshiftCliException: Failed to lookup the Organization ID for organization 'import-testing'
---> OctoshiftCLI.OctoshiftCliException: Unauthorized. Please check your token and try again
---> System.Net.Http.HttpRequestException: GitHub API error: {"message":"Bad credentials","documentation_url":"https://docs.github.com/graphql"}
---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
```
I haven't looked on how errors are surfaced in Octoshift, and I know each provider has its own set of error codes for different errors, but it would be really nice to surface a user friendly error that shows the correct perms needed!
Contributor guide
Assessment
This issue has not been assessed yet.