Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Bug: pagination next object does not "lack" on the last page

Greetings Atlassian,

According to the pagination documentation, the `next` property of a paginated collection is the recommended way to 'loop' through your collections.

Expected

The last page of a collection should omit the value of `next` to indicate this is the last page, as described in the documentation.

Lack of a next link in the response indicates the end of the collection.

Actual

On the last page of a collection, the `next` value actually links back to the first page:

{  
"page": 2,
...
"size": 38,
"next": "http://bitbucket-pipelines.prod.public.atl-paas.net/rest/1.0/accounts/{UUID}/repositories/{REPO_UUID}/variables?page=3&pagelen=10",
"previous": "http://bitbucket-pipelines.prod.public.atl-paas.net/rest/1.0/accounts/{UUID}/repositories/{REPO_UUID}/variables?page=1&pagelen=10",
"pagelen": 10
}

Work around

The workaround is to of course generate your own URL, but the whole purpose is to not have to do this:

However, clients are not expected to construct URLs themselves by manipulating the page number query parameter. Instead, the response contains a link to the next page. This link should be treated as an opaque location that is not to be constructed by clients or even assumed to be predictable.

1 answer

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Feb 01, 2023

Hi Sander,

This looks like a bug with the repository variables endpoint. There are actually two bugs:

The first one is that the links for "previous" and "next" are invalid, as you can see in the sample response you posted here. This bug is tracked in the following bug report: https://jira.atlassian.com/browse/BCLOUD-20910

The "next" field is indeed present even when there is no next page. I created a bug report for this here: https://jira.atlassian.com/browse/BCLOUD-22441

If you have less than 100 repository variables, you can use ?pagelen=100 in the API call (100 is the maximum allowed value for pagelen for this endpoint). All variables will then be returned in one page, and the "next" field will not be included in the response.

Kind regards,
Theodora

Thanks for dissecting the scenario in smaller issues, and link/creating the appropriate tickets :)

The use-case is needed for an infinite amount of results (used for a Terraform Provider), as such I will likely construct my own pagination URL increasing the page parameter in every iteration.

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events