-
Bug
-
Resolution: Unresolved
-
Low
-
2
-
Severity 3 - Minor
-
149
-
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:
Steps to Reproduce
- 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/
- 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.