Uh oh!
There was an error while loading. Please reload this page.
fix(server): use Bitbucket workspace permissions endpoint - #9035
Open
OliStarCooke wants to merge 1 commit into
Open
fix(server): use Bitbucket workspace permissions endpoint#9035OliStarCooke wants to merge 1 commit into
OliStarCooke wants to merge 1 commit into
Conversation
Replace the removed user-wide permissions preflight with Bitbucket's supported workspace-scoped endpoint so pull request writes are not blocked by HTTP 404.\n\nCloses pingdotgg#9034
Contributor
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This focused server fix replaces a retired Bitbucket permissions endpoint and changes the permission preflight used for pull-request write capabilities. Because it modifies production access-control behavior, human review is warranted despite the small, tested diff. You can add or adjust custom eligibility rules. Learn more. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
Bitbucket pull request permission checks now use the supported, workspace-scoped endpoint:
GET /2.0/user/workspaces/{workspace}/permissions/repositoriesThe server still filters the response to the requested repository and decodes the same effective
admin,write, orreadpermission. The old HTTP 410 fallback was removed with the retired endpoint.A regression test makes any request to the old endpoint fail with HTTP 404 and verifies that the supported endpoint succeeds. The existing authentication-failure coverage remains in place.
Why
Before every pull request write,
PullRequestServiceasks the provider for the viewer's permissions. T3 Code used Bitbucket's removed/user/permissions/repositoriesendpoint for that preflight. Some Bitbucket accounts now receive HTTP 404 from the endpoint, sogetViewerPermissionsfailed and the server never sent the requested comment.The replacement endpoint reports the authenticated caller's effective repository permissions and accepts the existing
read:repository:bitbucketAPI-token scope. Using it fixes the preflight without hiding real HTTP 401, HTTP 403, network, or response-decoding failures.Closes#9034
Verification
vp test run apps/server/src/pullRequest/BitbucketPullRequestApi.test.ts apps/server/src/pullRequest/BitbucketPullRequestProvider.test.ts— 47 tests passedgit diff --checkpassedThis was not tested by posting a comment to a live Bitbucket Cloud pull request.
Checklist
Authored with gpt-5.6-sol via the Codex harness in T3 Code.
Note
Medium Risk
Touches preflight permission checks before Bitbucket PR writes; wrong endpoint or decoding could block comments/merges, though scope is limited to Bitbucket integration code with updated tests.
Overview
Bitbucket repository permission preflight now calls
GET /user/workspaces/{workspace}/permissions/repositoriesinstead of the retired/user/permissions/repositoriesroute, using the workspace parsed fromworkspace/slugwhile keeping the samerepository.full_namefilter and permission decoding.The HTTP 410 “endpoint removed” workaround is gone:
getRepositoryPermissionno longer treats a deprecated-endpoint response as “permission unknown → allow” and instead surfaces real API outcomes (e.g. 401 still fails the read).Tests were updated to assert the new URL, exercise success via the workspace endpoint when other URLs would 404, and rename the auth-failure case accordingly.
Reviewed by Cursor Bugbot for commit da055cd. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Switch
BitbucketPullRequestApi.getRepositoryPermissionto workspace permissions endpointReplaces the deprecated
/user/permissions/repositoriescall with/user/workspaces/{workspace}/permissions/repositories(workspace URL-encoded). The filter query and escaping behavior are unchanged.isRepositoryPermissionRemovedErrorhelper and its special-case catch that treated an HTTP 410 from the old endpoint as an implicit grant.true; callers ofgetRepositoryPermissionthat relied on the old 410-as-success behavior in BitbucketPullRequestApi.ts will see different results when the endpoint returns 410.Macroscope summarized da055cd.