terminus
terminus copied to clipboard
Bitbucket Client error: for "terminus -v build:env:delete:pr "$TERMINUS_SITE" --yes"
Platform
( ) MacOS ( ) Linux ( ) Winderz
Installed Via
( ) Homebrew ( ) Apt Package ( ) Manually
PHP Version
( ) 7.4x ( ) 8.0 ( ) 8.1
Command Executed
"terminus -v build:env:delete:pr "$TERMINUS_SITE" --yes"
Expected behavior
I had expected for the command to check the pull requests and if they are merged delete the multi-dev environment from Pantheon.
Actual behavior
Getting a client error saying unauthorized even though the token is set as secret
[notice] Call Bitbucket API: GET repositories/{org}/{repo}/pullrequests?state=MERGED%26state%3DDECLINED%26state%3DSUPERSEDED%26state%3DOPEN
[error] Client error: GET https://api.bitbucket.org/2.0/repositories/{org}/{repo}/pullrequests?state=MERGED%26state%3DDECLINED%26state%3DSUPERSEDED%26state%3DOPEN resulted in a 401 Unauthorized response
Kind of disheartening that there hasn't been a response to this issue. It's completely derailed some of our build processes and now we have to go in and manually delete several multidev environments in order for our build to pass.
I created an internal ticket, https://getpantheon.atlassian.net/browse/CMS-753, to track this. If you encounter bugs that are interfering with your development workflow, submitting a support request will generally be higher visibility than reporting through GitHub, especially if you have a support contract.
One thing that comes to mind, though, is to ensure that the token that you've set has the right roles to delete PRs. That is one thing that could cause this symptom.
Thanks, @greg-1-anderson. It's always great to see an issue being addressed by you. This has been an issue since 3/1/2022 when Bitbucket changed their API. The error
[error] Client error: `GET https://api.bitbucket.org/2.0/repositories/myrepo/myproject/pullrequests?state=MERGED%26state%3DDECLINED%26state%3DSUPERSEDED%26state%3DOPEN` resulted in a `401 Unauthorized` response
looks like it's not trying to delete the PRs, but get a list.
I believe that the issue itself is from within https://github.com/pantheon-systems/terminus-build-tools-plugin since the command throwing the error is defined in that addon, however I found this issue was created and I did not want to create a duplicate issue
Ah, great, that's good info. We'll assign someone to look at this and update the API call.
@greg-1-anderson Have there been any updates to this or an issue that can be linked back to this one?
Opened per support recommendation.
Hi!
A super delayed but important update on this: in the ticket Greg mentioned above, we did some investigation and found that the issue was missing permissions on the App Password. We documented this in https://docs.pantheon.io/guides/build-tools/create-project/#access-tokens-optional
I just replied to @ozheller-nerd in the new issue in the build tools plugin.
I'm going ahead and close this issue; feel free to reopen/open a new one in terminus-build-tools if you still have related issues