Skip to content

Conversation

danielhoult
Copy link

Description

Support nextPageToken and the the new Jira /search/jql endpoint

Issues Resolved

Resolves #6015

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Collaborator

@san81 san81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the nice contribution. I have a few simple comments but other than that, this is a really good change to move out of the deprecated api.

nextPageToken = searchIssues.getNextPageToken();
addItemsToQueue(issueList, itemInfoQueue);
} while (startAt < total);
} while (nextPageToken != null && !nextPageToken.isEmpty() && !nextPageToken.isBlank());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could have been simpler to rely on isLast?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but there could be a case where isLast is false but maybe a bug from Atlassian (yes, bugs even impact large companies) where we don't receive a nextPageToken. Ultimately, regardless of the value of isLast, we need nextPageToken to be a non-empty value to get the next page. Defensive programming..

uri = UriComponentsBuilder.fromHttpUrl(url)
.queryParam(MAX_RESULT, FIFTY)
.queryParam(NEXT_PAGE_TOKEN, nextPageToken)
.queryParam(JQL_FIELD, jql)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subsequent calls that are just fetching the next page, doesn't require jql query param.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid

uri = UriComponentsBuilder.fromHttpUrl(url)
.queryParam(MAX_RESULT, FIFTY)
.queryParam(JQL_FIELD, jql)
.queryParam(EXPAND_FIELD, EXPAND_VALUE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like, with the new FIELDS_FIELD query param added, we don't need previous EXPAND_FIELD. It can be removed in both the blocks

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Jira API documentation still reference both 'expand' and 'fields' so I assumed there is a use-case for both. Without assuming functionality, I felt it better to leave both. https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/#api-rest-api-3-search-jql-post

Copy link
Collaborator

@san81 san81 Sep 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this use case, we only need one of them. So we can just go with the newly introduced field describing the specific fields we want to fetch while searching through the tickets.

Comment on lines 28 to 29
public static final String EXPAND_FIELD = "expand";
public static final String EXPAND_VALUE = "all";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two fields can be removed as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per above comment, JIRA docs have both expand and fields. Maybe expand will be useful in the future?

public static final String EXPAND_FIELD = "expand";
public static final String EXPAND_VALUE = "all";
public static final String FIELDS_FIELD = "fields";
public static final String FIELDS_VALUE = "*all";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The query can be optimized to only fetch the specific fields needed for crawling while navigating over search results. While fetching the page, it can fetch all fields.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to make sure that I understand. Are you saying that an initial query is made to retrieve a list of issues, in which case we only need the id/key. Then those are added to a queue, and an iterator fetches the issues one by one?
I suspected that this may be the case, but was not sure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is right. Initial search query returns the he list of issues with id, project, created datetime and last modified datetime attributes and then an other threads kicks in to fetch those items individually.

@san81 san81 self-requested a review September 12, 2025 23:34
@san81
Copy link
Collaborator

san81 commented Sep 22, 2025

@danielhoult Could you please take care of these minor comments so that we can go ahead and merge these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Atlassian Jira Cloud needs new endpoint for JQL search.
2 participants