gh-gei
gh-gei copied to clipboard
BBS: An invalid PAT should surface a user friendly error
Description
Both an invalid PAT and a PAT that does not have enough permissions will return a 401 error.
Currently for both we get the following error:
[2023-10-18 08:21:28] [INFO] You are running the latest version of the bbs2gh extension [v1.2.1]
[2023-10-18 08:21:28] [INFO] BBS SERVER URL: https://test-bbs-o.githubapp.com/
[2023-10-18 08:21:28] [INFO] BBS PROJECT: IM
[2023-10-18 08:21:28] [INFO] BBS REPO: test-commit-id-blank-review
[2023-10-18 08:21:28] [INFO] SSH PORT: 22
[2023-10-18 08:21:28] [INFO] VERBOSE: true
[2023-10-18 08:21:28] [DEBUG] HTTP POST: https://test-bbs-o.githubapp.com/rest/api/1.0/migration/exports
[2023-10-18 08:21:29] [DEBUG] HTTP BODY: {"repositoriesRequest":{"includes":[{"projectKey":"IM","slug":"test-commit-id-blank-review"}]}}
[2023-10-18 08:21:29] [DEBUG] RESPONSE (Unauthorized): {"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}
It would be nice to surface a user friendly error noting the correct perms needed.
Reproduction Steps
export BBS_USERNAME=unit-test export BBS_PASSWORD="fake-pat" OR "correct pat with not enough perms"
export AWS_REGION=us-west-1
export AWS_ACCESS_KEY_ID=<VALID_KEY>
export AWS_SECRET_ACCESS_KEY=<VALID_ACCESS_KEY>
gh bbs2gh migrate-repo --bbs-server-url https://test-bbs-o.githubapp.com/ --bbs-project IM --bbs-repo test-commit-id-blank-review