[Bug]: Bitbucket merge still fails — removed /user/permissions/repositories endpoint returns 404, not 410
Summary
Merging a Bitbucket Cloud pull request from T3 Code fails with Bitbucket returned HTTP 404. The failure comes from the viewer-permission gate, not the merge call: GET /2.0/user/permissions/repositories was removed by Bitbucket (CHANGE-2770), and production Bitbucket answers 404 for it — but the fallback added in #6525 only recognises 410, so the removed-endpoint path never triggers and every write action is blocked.
Version
- T3 Code
0.0.34-nightly.20260824.1179(trace below) and0.0.35-nightly.20260826.1195;mainstill has the same check atapps/server/src/pullRequest/BitbucketPullRequestApi.ts:118. - Linux (NixOS), AppImage build.
- Bitbucket Cloud, user API token.
GET /2.0/userand all PR listing calls succeed with the same credential.
Trace
From ~/.t3/userdata/logs/server.trace.ndjson:
ws.rpc.pullRequests.runAction -> Failure
PullRequestOperationError: Pull request operation runAction failed: Bitbucket returned HTTP 404.
[cause]: PullRequestProviderError: bitbucket failed in getViewerPermissions: Bitbucket returned HTTP 404.
[cause]: BitbucketResponseError: Bitbucket API failed in request: Bitbucket returned HTTP 404.
The failing HTTP span:
GET https://api.bitbucket.org/2.0/user/permissions/repositories?q=repository.full_name%3D%22<workspace>%2F<repo>%22
http.response.status_code: 404
Confirming the endpoint is gone (not a permission problem)
Unauthenticated probes, so no token is involved:
$ curl -s -o /dev/null -w '%{http_code}\n' https://api.bitbucket.org/2.0/user
401
$ curl -s -o /dev/null -w '%{http_code}\n' 'https://api.bitbucket.org/2.0/user/permissions/repositories?q=repository.full_name%3D%22x%2Fy%22'
404
$ curl -s -o /dev/null -w '%{http_code}\n' https://api.bitbucket.org/2.0/user/permissions/workspaces
404
An existing endpoint answers 401 without auth; the removed ones answer 404 regardless of auth.
Cause
#6525 (closes #6341) added:
function isRepositoryPermissionRemovedError(error) {
return error._tag === "BitbucketResponseError" && error.status === 410;
}
The PR notes it was not exercised against a live Bitbucket account and was coded to the documented 410. Real Bitbucket returns 404, so getRepositoryPermission still hard-fails, getViewerPermissions fails, and PullRequestService.viewerPermissionsOf blocks merge (and other writes) before the merge request is sent.
Suggested fix
Treat 404 from /2.0/user/permissions/repositories the same as 410 in isRepositoryPermissionRemovedError (permission unknown → not blocking), and update the unit test to cover both statuses. Happy to send a PR.
Same root cause also blocks a read-only path: the reviewer picker on a Bitbucket pull request.
reviewerCandidates calls getViewerPermissions before it lists candidates, so opening Reviewers → add fails with The people with access could not be read. Pull request operation reviewerCandidates failed: Bitbucket returned HTTP 404. Nothing is being written, so the preflight blocks reads as well as write actions.
Version
- T3 Code (Alpha) desktop on macOS 15 (Darwin 24.2.0), server runtime
0.0.40. t3@nightly0.0.41-nightly.20260908.1387still has the same check:isRepositoryPermissionRemovedErrormatches onlyerror.status === 410.
Trace
From ~/.t3/userdata/logs/server.trace.ndjson:
ws.rpc.pullRequests.reviewerCandidates -> Failure
PullRequestOperationError: Pull request operation reviewerCandidates failed: Bitbucket returned HTTP 404.
[cause]: PullRequestProviderError: bitbucket failed in getViewerPermissions: Bitbucket returned HTTP 404.
[cause]: BitbucketResponseError: Bitbucket API failed in request: Bitbucket returned HTTP 404.
The credential is fine — only the preflight fails
Same Atlassian account email + API token, scopes read:user:bitbucket, read:repository:bitbucket, write:repository:bitbucket, read:pullrequest:bitbucket, write:pullrequest:bitbucket, read:workspace:bitbucket:
GET /2.0/user -> 200
GET /2.0/repositories/<workspace>/<repo>/pullrequests -> 200
GET /2.0/workspaces/<workspace>/members -> 200 (the candidate list itself)
GET /2.0/user/permissions/repositories?q=... -> 404 {"detail": "There is no API hosted at this URL."}
GET /2.0/user/permissions/workspaces -> 404 same body
So listReviewerCandidates would succeed on its own; only the removed permission endpoint stands in the way.
Note on the 404 body
Bitbucket answers 404 with There is no API hosted at this URL. rather than 410, for both /user/permissions/repositories and /user/permissions/workspaces — the path itself is gone, not the row. Tolerating 404 in addition to 410 would need to avoid swallowing a genuine "repository not found", e.g. by keying on that removal body or by dropping the preflight and letting the actual operation report its own error.
Still reproducible on macOS arm64 with T3 Code desktop nightly 0.0.46-nightly.20261013.3042. PR reads return 200, but clicking Merge fails in getViewerPermissions: GET /2.0/user/permissions/repositories returns 404. The installed bundle still handles only 410 in isRepositoryPermissionRemovedError, blocking the action before the merge request.
Investigated with Codex (GPT-6).
[!NOTE] Grok responding on behalf of Julius.
Fixed by https://github.com/pingdotgg/t3code/pull/10984 — Bitbucket permission checks now use the workspace-scoped endpoint, so the retired /user/permissions/repositories 404 no longer blocks merges and other writes.