Migrate Jira integration from deprecated API v2 to v3 endpoints#117
Migrate Jira integration from deprecated API v2 to v3 endpoints#117
Conversation
Co-authored-by: zkoppert <6935431+zkoppert@users.noreply.github.com>
|
Cc/ @jacksonblalock |
There was a problem hiding this comment.
Pull request overview
Updates the Jira client initialization to target Jira REST API v3 endpoints, addressing failures caused by removed v2 endpoints in newer Jira environments.
Changes:
- Configure the python-jira
JIRAclient withoptions={"api_version": 3}.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jiralib.py
Outdated
| self.user = user | ||
| self.token = token | ||
| self.j = JIRA(url, basic_auth=(user, token)) | ||
| self.j = JIRA(url, basic_auth=(user, token), options={"api_version": 3}) |
There was a problem hiding this comment.
This hard-codes Jira REST API v3 for all deployments. The repo documentation and CLI/action inputs currently describe targeting a “Jira Server instance”; Jira Server/Data Center may not expose the v3 REST API, so this change could break those users. Consider making the REST API version configurable (e.g., input/env var with a default aligned to documented support) or implementing a simple fallback/auto-detect, and update the docs accordingly.
There was a problem hiding this comment.
Added this line, but it seems that it does not change the outcome. I am getting the same error, but pasting a cleaned trace below.
Syncing salesforce...
/home/[user]/.local/share/virtualenvs/ghas-jira-integration-[hash]/lib/python3.12/site-packages/jira/init.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import pkg_resources
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): [company].atlassian.net:443
DEBUG:urllib3.connectionpool:https://[company].atlassian.net:443 "GET /rest/api/2/serverInfo HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://[company].atlassian.net:443 "GET /rest/api/2/field HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://[company].atlassian.net:443 "GET /rest/api/2/search?jql=project%3D%22VULN%22+and+description++%22[hash]%22&startAt=0&validateQuery=True HTTP/1.1" 410 None+%22[hash]%22&startAt=0&validateQuery=True
Traceback (most recent call last):
File "/home/[user]/ghas-jira/tools/ghas-jira-integration/cli.py", line 321, in
main()
File "/home/[user]/ghas-jira/tools/ghas-jira-integration/cli.py", line 318, in main
args.func(args)
File "/home/[user]/ghas-jira/tools/ghas-jira-integration/cli.py", line 99, in sync
state = jira_project.fetch_repo_state(repo_id, args.state_issue)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/[user]/ghas-jira/tools/ghas-jira-integration/jiralib.py", line 147, in fetch_repo_state
i = self.get_state_issue(issue_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/[user]/ghas-jira/tools/ghas-jira-integration/jiralib.py", line 122, in get_state_issue
self.j.search_issues(issue_search, maxResults=0),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/[user]/.local/share/virtualenvs/ghas-jira-integration-[hash]/lib/python3.12/site-packages/jira/client.py", line 2523, in search_issues
issues = self._fetch_pages(
^^^^^^^^^^^^^^^^^^
File "/home/[user]/.local/share/virtualenvs/ghas-jira-integration-[hash]/lib/python3.12/site-packages/jira/client.py", line 636, in _fetch_pages
resource = self._get_json(request_path, params=page_params, base=base)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/[user]/.local/share/virtualenvs/ghas-jira-integration-[hash]/lib/python3.12/site-packages/jira/client.py", line 3139, in _get_json
r = self._session.get(url, params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/[user]/.local/share/virtualenvs/ghas-jira-integration-[hash]/lib/python3.12/site-packages/jira/resilientsession.py", line 172, in get
return self.__verb("GET", url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/[user]/.local/share/virtualenvs/ghas-jira-integration-[hash]/lib/python3.12/site-packages/jira/resilientsession.py", line 168, in __verb
raise_on_error(response, verb=verb, **kwargs)
File "/home/[user]/.local/share/virtualenvs/ghas-jira-integration-[hash]/lib/python3.12/site-packages/jira/resilientsession.py", line 53, in raise_on_error
raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 410 url: https://[company].atlassian.net/rest/api/2/search?jql=project%3D%22VULN%22+and+description+
text: 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
response headers = {'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Fri, 13 Feb 2026 16:25:47 GMT', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': '[request-id]', 'X-Seraph-Loginreason': 'AUTHENTICATED_FAILED', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': '[trace-id]', 'Atl-Request-Id': '[request-id]', 'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload', 'Report-To': '{"endpoints": [{"url": "https://[cdn-url]"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.01, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}', 'Server-Timing': 'atl-edge;dur=71,atl-edge-internal;dur=17,atl-edge-upstream;dur=54,atl-edge-pop;desc="aws-us-east-1"', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 [cloudfront-id].cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'DEN53-P3', 'X-Amz-Cf-Id': '[cloudfront-request-id]'}
response text = {"errorMessages":["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"],"errors":{}}
Key Issue: The Jira API v2 endpoint has been deprecated. You need to update your code to use /rest/api/3/search/jql instead of /rest/api/2/search.
…onfigurability - Fix option key: 'api_version' -> 'rest_api_version' (the wrong key was silently ignored, causing requests to still hit /rest/api/2/ endpoints) - Upgrade jira library from ~=3.0.0 to ~=3.10.0 (adds support for the new /rest/api/3/search/jql endpoint via enhanced_search_issues) - Replace search_issues() with enhanced_search_issues() at both call sites to use the new search endpoint - Make API version configurable via --jira-api-version CLI arg, jira_api_version action input, and GH2JIRA_JIRA_API_VERSION env var (defaults to '3' for Jira Cloud, use '2' for Jira Server/Data Center) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@jacksonblalock Thanks for testing and reporting back with the detailed trace — that was very helpful in diagnosing the issue. The original fix had three problems:
I just pushed a commit that fixes all three issues:
Could you test again with these changes and let us know if it resolves the 410 errors? Thanks! |
Atlassian removed Jira API v2 endpoints (
/rest/api/2/search,/rest/api/2/field,/rest/api/2/serverInfo) effective May 2025. The integration was failing with "The requested API has been removed. Please migrate to the /rest/api/3/search/jql API."Changes
options={"api_version": 3}to the JIRA client constructor injiralib.pyThis ensures all API calls automatically use the v3 endpoints:
/rest/api/2/search→/rest/api/3/search/jql/rest/api/2/field→/rest/api/3/field/rest/api/2/serverInfo→/rest/api/3/serverInfoOriginal prompt