jira-cli icon indicating copy to clipboard operation
jira-cli copied to clipboard

Pagination with the new JQL endpoint

Open cpaelzer opened this issue 3 months ago • 4 comments

Describe the bug

jira issue list is more be able to paginate.

I initially realized that a loop that was iterating paginating over 30 issues at a time to have gotten an infinite loop. From there I simplified my command (in case my JQL would be too complex or any such) and see the following all return the very same two issues as result:

jira issue list --jql 'project in (SD)' --plain --no-headers --paginate 0:2
jira issue list --jql 'project in (SD)' --plain --no-headers --paginate 1:2
jira issue list --jql 'project in (SD)' --plain --no-headers --paginate 2:2
jira issue list --jql 'project in (SD)' --plain --no-headers --paginate=2

--paginate is just silently ignored. Yet the limit still is a 100, which makes me unable to fetch the full set I want and need (currently 115)

  1. JiraCLI Version:
(Version="main", GitCommit="79067e2422df10e59f310bd6fd4979f43a1df0e7", CommitDate="2025-08-30T08:30:25+00:00", GoVersion="go1.24.1", Compiler="gc", Platform="linux/amd64")
  1. Are you using Jira cloud or on-premise jira server?
SERVER INFO
-----------

Version:         1001.0.0-SNAPSHOT
Build Number:    100289
Deployment Type: Cloud
Default Locale:  en_US
  1. What operating system are you using? Also mention version.
Ubuntu 24.04.3 LTS (Noble Numbat)
  1. What terminal are you using?
tilix at version 1.9.6-2build1

To Reproduce

Steps to reproduce the behavior:

  1. run jira issue list --jql <any works> --paginate 2:2
  2. compare it with jira issue list --jql <any works> --paginate 0:2

And see it has no effect - the result is the same

I know that you had to change the endpoint. After all the old version triggered

Error:
  - The requested API has been removed. Please migrate to the /rest/api/3/search/jql API. A full migration guideline is available at https://developer.atlassian.com/changelog/#CHANGE-2046

jira: Received unexpected response '410 Gone'.
Please check the parameters you supplied and try again.

AFAICS that led to this commit d796db28ac2df9d42f9809b635791f784140a47b "fix: Update deprecated endpoint (https://github.com/ankitpokhrel/jira-cli/pull/892)"

In there I gladly found that this is non surprising, #892 describes it.

Expected behavior

Ideally paginate to work, the result of the output above to be different and to be able to fetch more than 100 items again with --paginate 100:x. But otherwise at least - since it is known shouldn't --paginate 1:2 at least return an error that this is no more working instead of silently returning the same results no matter what?

Furthermore while the PR says:

... Users can still paginate using the maxResults parameter (e.g., --paginate=10).

But I was not yet able to get my results >100. --paginate=110 is refused with Error: invalid argument for paginate: Format <from>:<limit>, where <from> is optional and <limit> must be between 1 and 100 (inclusive)

I might be missing the point, but how would I get the issues >100 in the example above?

cpaelzer avatar Sep 11 '25 08:09 cpaelzer

I am seeing this also, but doesn't require --jql. These both return the same issue:

jira issue list --paginate 1:1
jira issue list --paginate 2:1

I'm running

(Version="v1.7.0", GitCommit="", CommitDate="", GoVersion="go1.24.1", Compiler="gc", Platform="darwin/arm64")

wholtz avatar Sep 12 '25 16:09 wholtz

I just noticed that the release notes for v1.7.0 address this issue:

Consequently, the startAt parameter in the new API is unsupported. Therefore, the from part of the --paginate=: flag is effectively ignored. Users can still paginate using the maxResults parameter (e.g., --paginate=10).

I hope there is some way to regain the ability to pull more than the first 100 issues.

wholtz avatar Sep 12 '25 16:09 wholtz

Yeah @wholtz that is exactly what I see too. I mentioned the same as that comment in the 1.7.0 release is from #892 which I referred to. Both our problem is that this comment says

Users can still paginate using the maxResults parameter (e.g., --paginate=10).

And that sounds relieving ...

Until you realize all it can do is limit the number of issues fetched, but will always start from the first. Which then reaches its limit at >100

cpaelzer avatar Sep 15 '25 10:09 cpaelzer

There are two fields in the new API:

isLast , nextPageToken

Just need to check isLast (bool) and if false, resubmit the current POST with the nextPageToken from the current response.

I've not written any Go since 2017, or I'd create a PR.

wwalker avatar Oct 15 '25 13:10 wwalker