[Bitbucket Cloud] broken pagination in "next" link in json response

Setup: A node web application that queries the bitbucket api. For testing I am using an app password tied to my personal user account. I have turned the requests into standard curl commands to demonstrate the issue.

The first request works without a problem (responses truncated)

$ curl -sL --user "$BITBUCKET_CLOUD_USERNAME:$BITBUCKET_CLOUD_PASSWORD" 'https://api.bitbucket.org/2.0/workspaces/<WORKSPACE REDACTED>/search/code?page=1&pagelen=100&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml' | jq . | head
{
  "size": 712,
  "page": 1,
  "pagelen": 100,
  "next": "https://api.bitbucket.org/2.0/workspaces/%7Be986b1b2-873b-4c51-8364-9da80494e59b%7D/search/code&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml&pagelen=100&page=2",
  "query_substituted": false,
  "values": [
    {
      "type": "code_search_result",
      "content_match_count": 4,

The issue comes from the “next” value in the response JSON:

https://api.bitbucket.org/2.0/workspaces/%7Be986b1b2-873b-4c51-8364-9da80494e59b%7D/search/code&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml&pagelen=100&page=2

This is not a valid link, code&search_query should be code?search_query, and it is causing errors in my application, since trying to call that link gives me a 404 error:

curl -sL --user "$BITBUCKET_CLOUD_USERNAME:$BITBUCKET_CLOUD_PASSWORD" 'https://api.bitbucket.org/2.0/workspaces/%7Be986b1b2-873b-4c51-8364-9da80494e59b%7D/search/code&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml&pagelen=100&page=2'
{"type": "error", "error": {"message": "Resource not found", "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/"}}%

@CassidyMarble,

That’s very clearly a bug. Could you please report that to our developer support team to get logged & triaged appropriately? In case other people have the same problem, it would be great if you could let us know the issue key once they log the issue.

@ibuchanan Thank you for the link! I made a ticket in the servicedesk.

We have an open bug report for this issue with our Bitbucket Cloud team, which the link is available at: https://jira.atlassian.com/browse/BCLOUD-23130.

Best regards,
Guilherme

1 Like