commits changes REST API doesn't return more than 1000 files

Itay Neeman July 1, 2015

I'm trying to use the Changes REST API for commits:

https://developer.atlassian.com/static/rest/stash/3.10.2/stash-rest.html#idp2936368

I issue a request to a URL like this:

url = "https://" + server + "/rest/api/1.0/projects/" + project + "/repos/" + repo + "/commits/" + commit + "/changes?withComments=0&limit=50&since=" + fromCommit + "&start=" + str(start)

And I can properly paginate until I reach offset 1000. However, after that point, it just stops behaving correctly, specifically, I have an endless chain of:

{
 "fromHash": "60895ebabd48e0e03fd69f02ebf80e084b2b46a9", 
 "isLastPage": false, 
 "limit": 50, 
 "nextPageStart": 1050, 
 "size": 0, 
 "start": 1000, 
 "toHash": "061185d0872b98cc6940d8d3f1c70365e418aeea", 
 "values": []
}
{
 "fromHash": "60895ebabd48e0e03fd69f02ebf80e084b2b46a9", 
 "isLastPage": false, 
 "limit": 50, 
 "nextPageStart": 1100, 
 "size": 0, 
 "start": 1050, 
 "toHash": "061185d0872b98cc6940d8d3f1c70365e418aeea", 
 "values": []
}
{
 "fromHash": "60895ebabd48e0e03fd69f02ebf80e084b2b46a9", 
 "isLastPage": false, 
 "limit": 50, 
 "nextPageStart": 1150, 
 "size": 0, 
 "start": 1100, 
 "toHash": "061185d0872b98cc6940d8d3f1c70365e418aeea", 
 "values": []
}
{
 "fromHash": "60895ebabd48e0e03fd69f02ebf80e084b2b46a9", 
 "isLastPage": false, 
 "limit": 50, 
 "nextPageStart": 1200, 
 "size": 0, 
 "start": 1150, 
 "toHash": "061185d0872b98cc6940d8d3f1c70365e418aeea", 
 "values": []
}

 The previous object prior to this looked like this:

{
 "fromHash": "60895ebabd48e0e03fd69f02ebf80e084b2b46a9", 
 "isLastPage": false, 
 "limit": 50, 
 "nextPageStart": 1000, 
 "size": 50, 
 "start": 950, 
 "toHash": "061185d0872b98cc6940d8d3f1c70365e418aeea", 
 "values": [ ... ]
}

i.e. it did have values in it.

I'm using Stash 3.6.0. I've tried this with different limit values, but no dice, it always stops after 1000. I've verified manually in Git, this particular changeset should have about 6000 file changes.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 1, 2015

Hi Itay,

It looks like you're running into https://jira.atlassian.com/browse/STASH-5329

The page.max.changes parameter (can be overwritten in stash-config.properties) defaults to 1000. This is a hard limit and changes above 1000 are not shown. 

For the REST API, isLastPage should continue to return false as there are more results, but nextPageStart should return null instead of continue to count up in increments of the page size. This is what the bug above is describing. 

Itay Neeman July 1, 2015

Jeff Thomas [Atlassian] I assume that there is no way to override that particular property per REST call, or even update it without restart. Is that correct? Assuming it is, it makes this kind of useless. For normal operations, I do not want people to be able to go over 1000 changes, for example. But for some scripts that we run on a schedule, I would want to be able to get all this info, which I can't.

Jeff Thomas
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 1, 2015

You're correct, there's no way to change this value without modifying the property in stash-config.properties and restarting, then the new limit is global. We're tracking an improvement to this at https://jira.atlassian.com/browse/STASH-5328 so that the limit is different for the REST API and can exceed what's set in page.max.changes to get all of the changes.

Itay Neeman July 1, 2015

Thanks. I've voted for both issues and am watching them, but I'm not holding my breath given the track record here (and with other issues we've filed through the official support channel), unfortunately..

Sergey Svishchev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 2, 2015

> nextPageStart should return null instead of continue to count up in increments of the page size. This behaviour is not documented on https://developer.atlassian.com/static/rest/stash/3.10.2/stash-rest.html -- does it apply to this API call only or to all calls?

TAGS
AUG Leaders

Atlassian Community Events