Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-22441

"Next" field is returned for repository variables API even when there is no next page

XMLWordPrintable

      Issue Summary

      API calls that return a paginated response include a field named "next" in the response with a link to the next page. The lack of a "next" link in the response indicates the end of the collection.

      However, the following API endpoint includes the field "next" on the last page:

      https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-pipelines-config-variables-get

      Steps to Reproduce

      1. Use the following API endpoint with a repo that has 11 repository variables
        curl -u Username:AppPassword -X GET -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pipelines_config/variables/
      2. This call will return 10 variables. The value of "next" is invalid, something documented in this bug report: https://jira.atlassian.com/browse/BCLOUD-20910

      Construct manually the URL for the next page as follows:

      curl -u Username:AppPassword -X GET -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pipelines_config/variables/?page=2

      (The "next" links are not supposed to be constructed manually, however in this case this link provides the second page)

      Expected Results

      The API call returns the second page, and the field "next" is not included in the response as it is the last page.

      Actual Results

      The API call returns the second page, and the field "next" is included in the response, even though there is no next page.

      Workaround

      Use ?pagelen=100 in the API call. This should work ok if there are less than 100 variables in the repo.

      curl -u Username:AppPassword -X GET -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/workspace-id/repo-slug/pipelines_config/variables/?pagelen=100

      In this case, the field "next" is not returned in the response.

              Unassigned Unassigned
              tboudale Theodora Boudale (Inactive)
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated: