fix(bitbucket): migrate off cross-workspace APIs removed by CHANGE-2770#8916
Open
KennethWKZ wants to merge 4 commits into
Open
fix(bitbucket): migrate off cross-workspace APIs removed by CHANGE-2770#8916KennethWKZ wants to merge 4 commits into
KennethWKZ wants to merge 4 commits into
Conversation
Contributor
|
Nice. Did you test it locally? |
- listBitbucketWorkspaces: replace GET /user/permissions/workspaces with the supported GET /workspaces (lists the current user's workspaces). Workspace slug/name now parsed from the top level of each value instead of a nested "workspace" object.
- searchBitbucketRepos: replace cross-workspace GET /repositories?role=member with per-workspace GET /repositories/{workspace}, enumerating the user's workspaces first and aggregating up to PageSize matches.
- models: flatten GroupResponse to match the /workspaces response shape.
4ac7d66 to
a2a7abd
Compare
…E-2770)
GET /2.0/workspaces is also deprecated, not just /user/permissions/workspaces.
The supported replacement for enumerating the current user's workspaces is
GET /2.0/user/workspaces, which nests slug/name under a workspace object.
- remote_api.go: listBitbucketWorkspaces / listAllBitbucketWorkspaces now call
/user/workspaces with workspace.* fields and read via GroupId()/GroupName().
- models/repo.go: re-nest GroupResponse under WorkspaceItem to match the
/user/workspaces response shape.
Repo listing stays on the supported GET /2.0/repositories/{workspace}.
…ld name) GET /2.0/user/workspaces rejects sort=workspace.slug with HTTP 400 'Invalid field name'. The bare paginated call returns the nested workspace objects we parse, so drop the sort/fields query params in both listBitbucketWorkspaces and listAllBitbucketWorkspaces.
Author
yes i testing in EC2 + self build docker image with pointing to our bitbucket cloud, working fine |
Bitbucket has sunset the issue tracker/wiki API; the issues endpoint now
returns 410 Gone instead of 404. ignoreHTTPStatus404 only mapped 404 to
ErrIgnoreAndContinue, so a 410 fell through to nil, DoAsync retried 3x and
failed the whole pipeline ("Collect Issues ended unexpectedly").
Treat 410 like 404 (ignore and continue). Shared helper also covers issue
comments and pr commits. Adds a table test for the status-code mapping.
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 free
to 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.
pr-type/bug-fix,pr-type/feature-development, etc.Summary
What does this PR do?
Bitbucket Cloud removed its cross-workspace REST APIs as part of CHANGE-2770. The Bitbucket plugin still called these endpoints, so listing/searching remote scopes failed with HTTP 410
CHANGE-2770 - Functionality has been deprecated:(410) {"type":"error","error":{"message":"CHANGE-2770 - Functionality has been deprecated"}}
github.com/apache/incubator-devlake/plugins/bitbucket/api.listBitbucketWorkspaces
/app/plugins/bitbucket/api/remote_api.go:89
This PR migrates the plugin onto the supported workspace-scoped endpoints:
GET /user/permissions/workspaceswith the supportedGET /workspaces(lists the current user's workspaces). Workspace slug/name now parsed from the top level of each value instead of a nested"workspace"object.GET /repositories?role=memberwith per-workspaceGET /repositories/{workspace}, enumerating the user's workspaces first and aggregating up to PageSize matches.GroupResponseto match the/workspacesresponse shape.The public
remote-scopes/search-remote-scopesAPI contract is unchanged, so config-ui and Grafana need no changes.Does this close any open issues?
N/A
Screenshots
N/A, no UI changes.
Other Information
Atlassian will not ship a cross-workspace
/repositoriesreplacement, so search now issues one request per workspace and collapses pagination to the firstPageSizematches — the only path the new API surface allows.Verified:
go build ./plugins/bitbucket/...passes; manual smoke test against a Bitbucket Cloud connection (browse workspaces → repos, search remote scopes).