Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Issue with bitbucket cloud and pagination. #321

Unanswered
cooper1101 asked this question in Support
Discussion options

I am running into an issue when getting repos for a workspace or project in bitbucket cloud. I am using a long-lived access token (tried with app password as well). When trying to get repos for a private workspace, the request fails.
I was able to narrow it down with extra loggers in the code to the following issue. When the initial request happens, it gets the response back with the results, in this case it's the first page, amount of results and pages as well as the next url. But when the request to the next url happens, that's where the request fails. The url in the next request is correct, can confirm with curl with the same access token. Running inside docker container and curl also was done from within the container. Here's a snippet of the extra logs:
[backend] | "pagelen": 10, [backend] | "size": 123, [backend] | "page": 1, [backend] | "next": "https://api.bitbucket.org/2.0/repositories/[redacted]?q=project.key%3D%22[redacted]%22&page=2" [backend] | } [backend] | 2025年05月30日T11:21:26.996Z info: [Bitbucket] url is https://api.bitbucket.org/2.0/repositories/[redacted]?q=project.key%3D%22[redacted]%22&page=2 [backend] | 2025年05月30日T11:21:27.173Z error: [Bitbucket] Failed to fetch repos for project [redacted]: Error: Failed to fetch projects for workspace [redacted]: { [backend] | "type": "error", [backend] | "error": { [backend] | "message": "Token is invalid, expired, or not supported for this endpoint." [backend] | } [backend] | }
Fetching repos one by one works when specifying the repos individually in the config, but this approach can't be used unfortunately. Any help is appreciated. Thanks.

You must be logged in to vote

Replies: 2 comments

Comment options

I tried using node-fetch in one of the functions in packages/backend/src/bitbucket.ts and it works for querying next pages. All repos got fetched fine down the road as well.

 const path = `https://api.bitbucket.org/2.0/repositories/${workspace}` as CloudGetRequestPath;
 const repos = await getPaginatedCloud<CloudRepository>(path, async (url) => {
 logger.info(`url is ${url}`)
 const response = await fetch(url, {
 method: 'GET',
 headers: {
 'Authorization': `Bearer ${process.env.BITBUCKET_TOKEN}`,
 'Accept': 'application/json'
 }
 })
 const data = await response.json();

It seems it's something with how the bitbucketclient handles the token when it needs to continue querying next pages.

You must be logged in to vote
0 replies
Comment options

That's very strange, thanks for looking into this! Seems like a bug within the bitbucket client library we're using here

If you could submit a PR that swaps bitbucketclient usage to node-fetch that would be amazing!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /