Skip to content

Conversation

@GoSimplicity
Copy link
Contributor

Fixed the Epic collector to use the new Jira API endpoint and ensured all required fields are included when fetching Epic data. This resolves the synchronization failures caused by the deprecated endpoint (fix #8544 ).

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. component/plugins This issue or PR relates to plugins needs-cherrypick-v1.0 pr-type/bug-fix This PR fixes a bug severity/p1 This bug affects functionality or significantly affect ux labels Aug 21, 2025
Copy link
Contributor

@klesh klesh left a comment

Choose a reason for hiding this comment

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

hanks for your contribution!
This should resolve the JIRA Cloud data collection issue.
However, I’m concerned it may not work with older JIRA Server versions.
I think we should detect the JIRA version and call the appropriate APIs accordingly.

For reference, here’s some related code:

if data.JiraServerInfo.DeploymentType == models.DeploymentServer && len(data.JiraServerInfo.VersionNumbers) == 3 && data.JiraServerInfo.VersionNumbers[0] <= 8 {

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Aug 25, 2025
@GoSimplicity
Copy link
Contributor Author

hanks for your contribution! This should resolve the JIRA Cloud data collection issue. However, I’m concerned it may not work with older JIRA Server versions. I think we should detect the JIRA version and call the appropriate APIs accordingly.

For reference, here’s some related code:

if data.JiraServerInfo.DeploymentType == models.DeploymentServer && len(data.JiraServerInfo.VersionNumbers) == 3 && data.JiraServerInfo.VersionNumbers[0] <= 8 {

Based on your suggestion, I have made the new and old version endpoints compatible.

Copy link
Contributor

@klesh klesh left a comment

Choose a reason for hiding this comment

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

That was fast — great job!

However, I made a mistake in pointing to an inappropriate line of code for this case.
The version check on line 54 was originally added because the performance of Jira versions ≤ 8 was quite poor, so we reduced the batch size to avoid overloading or crashing the Jira server.

In the current scenario, checking only the server type should be sufficient.
I'm not sure whether Jira Server 9 supports the api/v3 endpoint or not.

}
localJQL := fmt.Sprintf("issue in (%s) and %s", strings.Join(epicKeys, ","), jql)
query.Set("jql", localJQL)
query.Set("startAt", fmt.Sprintf("%v", reqData.Pager.Skip))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the information provided in the Atlassian developer changelog, the new api/3/search/jql endpoint has changed the way data is paginated. Specifically, random page access has been replaced with a continuation token API. This means that you won't be able to fetch multiple pages simultaneously using parallel threads. The startAt parameter has been replaced with nextPageToken.

Given these changes, simply updating the API endpoint without adjusting the pagination logic will result in incomplete data retrieval. The existing code that relies on the startAt parameter for pagination will no longer work as expected. It's crucial to implement the new nextPageToken mechanism to handle pagination properly and ensure that all data can be fetched correctly.

We’ll replace random page access with a continuation token API. This means you won’t be able to get multiple pages at the same time with parallel threads. startAt parameter will be replaced with nextPageToken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent catch on the pagination changes! You're absolutely correct that api/3/search/jql uses nextPageToken instead of startAt. I'll update the implementation to:
1.Use different pagination strategies based on the API version
2.Set concurrency to 1 for api/3 (sequential pagination only)
3.Handle the nextPageToken properly in the response parser
I'll revise the PR to address these issues. Would you prefer separate collector implementations for each API version, or a single collector with conditional logic?

Copy link
Contributor

Choose a reason for hiding this comment

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

There’s already a mechanism for handling this kind of API. Here’s how you can enable it:

  1. Specify GetNextPageCustomData in ApiCollectorArgs to extract the nextPageToken.

    • This token will be stored in the RequestData.CustomData field.
    • Note: this also forces the collector to run in sequential mode (no parallel fetching).
  2. In the Query function, read the CustomData and plug it into the query string.

Here’s an example:

GetNextPageCustomData: GetNextPageCustomData,
Query: GetQueryForNextPage,

@GoSimplicity
Copy link
Contributor Author

That was fast — great job!

However, I made a mistake in pointing to an inappropriate line of code for this case. The version check on line 54 was originally added because the performance of Jira versions ≤ 8 was quite poor, so we reduced the batch size to avoid overloading or crashing the Jira server.

In the current scenario, checking only the server type should be sufficient. I'm not sure whether Jira Server 9 supports the api/v3 endpoint or not.

You're right about the performance considerations for JIRA Server ≤ 8. I'll keep the reduced batch size for those versions. Regarding JIRA Server 9's support for api/v3, I'll need to investigate further and potentially add version-specific handling.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 25, 2025
@klesh
Copy link
Contributor

klesh commented Aug 27, 2025

I see that there are new commits, and the code looks good to me. Just to confirm, is it ready for merging? Have you tested it against Jira Cloud, and does the pagination work as expected?

@GoSimplicity
Copy link
Contributor Author

I see that there are new commits, and the code looks good to me. Just to confirm, is it ready for merging? Have you tested it against Jira Cloud, and does the pagination work as expected?

Yes, the code is ready for merging. I have done some testing and it works properly.

Copy link
Contributor

@klesh klesh left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks for your contribution

@klesh klesh merged commit c5a4fbf into apache:main Aug 27, 2025
10 checks passed
@v1bh0r v1bh0r mentioned this pull request Oct 7, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/plugins This issue or PR relates to plugins needs-cherrypick-v1.0 pr-type/bug-fix This PR fixes a bug severity/p1 This bug affects functionality or significantly affect ux size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Jira] Integration fails due to deprecated /api/2/search endpoint (HTTP 410)

3 participants