Reconcile created Jira issues
What does this MR do and why?
This MR implements the support for Jira's search and reconcile pattern to ensure newly created Jira issues appear immediately in the vulnerability related issues list.
Problem
Jira's /rest/api/3/search/jql endpoint (that we switched to in !206815 (merged)) uses eventual consistency, meaning newly created issues don't appear immediately in search results. When users create a Jira issue from a GitLab vulnerability, the issue sometimes won't show up in the related issues list until the page is refreshed.
Solution
This MR implements the backend changes needed for Atlassian's recommended search and reconcile pattern:
-
Automatic reconciliation for vulnerability searches: When searching for issues by
vulnerability_ids, theIssuesFinderautomatically looks up the related Jira issue keys from the database and passes them toCloudListServiceasreconcile_issue_ids. -
CloudListService reconciliation: The
Jira::Requests::Issues::CloudListServicetransformsreconcile_issue_idsinto thereconcileIssuesparameter and includes it in the Jira search API request. -
Transparent to users: The reconciliation happens automatically in the backend without requiring any frontend changes. When users search for issues related to a vulnerability, newly created Jira issues will appear immediately.
The reconcileIssues parameter tells Jira's search endpoint: "I expect these issue IDs to exist, so if they're not in your index yet, please include them anyway."
Implementation Details
- Added
jira_issue_keys_for_vulnerabilitiesclass method toVulnerabilities::ExternalIssueLinkmodel to safely query external issue keys - Updated
IssuesFinderto call this method when searching byvulnerability_idson Jira Cloud - Updated
CloudListServiceto accept and usereconcile_issue_idsparameter - Limited reconciliation to 50 vulnerabilities per request (Jira API limit)
- Only applies to Jira Cloud (not Server)
References
- !206815 (comment 2792137174) (design discussion to split this out)
- #569792 (closed) (original issue)
- #577380 (new issue)
Screenshots or screen recordings
How to set up and validate locally
- In GDK, select a project and configure the Jira integration
- See gdk.test_3000_gitlab-org_gitlab-test_-_settings_integrations_jira_edit for the settings
- If you require Jira Cloud credentials, I'm happy to share mine. Please contact me in Slack.
- If you don't have vulnerabilities in the project, use
bundle exec rake gitlab:seed:vulnerabilitiesto seed some. - Try to create a Jira issue for a vulnerability. The created issue should appear immediately in the related Jira issues widget.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

