-
Couldn't load subscription status.
- Fork 640
fix(jira): update epic collector to use new API endpoint and include #8547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 { |
…based on JIRA version
Based on your suggestion, I have made the new and old version endpoints compatible. |
… Cloud and Server versions
There was a problem hiding this 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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
-
Specify
GetNextPageCustomDatainApiCollectorArgsto extract thenextPageToken.- This token will be stored in the
RequestData.CustomDatafield. - Note: this also forces the collector to run in sequential mode (no parallel fetching).
- This token will be stored in the
-
In the
Queryfunction, read theCustomDataand plug it into the query string.
Here’s an example:
| GetNextPageCustomData: GetNextPageCustomData, | |
| Query: GetQueryForNextPage, |
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. |
…on and enhance error handling
|
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. |
There was a problem hiding this 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
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 ).