From ee4aef54cc678f07d9f08f7407dd7cb5b666489b Mon Sep 17 00:00:00 2001 From: hwdev Date: Wed, 18 Nov 2026 09:16:33 +0000 Subject: [PATCH] [Jira] JiraCloud: enhanced_jql uses the configured api_version enhanced_jql used to call the v3 endpoint every time. It will now make requests to the v2 endpoint if the JiraCloud client has been instantiated with api_version=2, and those clients will receive v2 responses. For default clients (api_version=3) the request is unchanged. Fixes #1717 --- atlassian/jira/jira_cloud.py | 4 ++-- docs/jira_cloud.rst | 4 ++-- tests/test_jira_cloud_clients.py | 9 +++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/atlassian/jira/jira_cloud.py b/atlassian/jira/jira_cloud.py index 9aef4be35..cb998359b 100644 --- a/atlassian/jira/jira_cloud.py +++ b/atlassian/jira/jira_cloud.py @@ -46,7 +46,7 @@ def enhanced_jql( limit: Optional[int] = None, expand: Optional[str] = None, ): - """Search Jira Cloud issues through the v3 enhanced JQL endpoint. + """Search Jira Cloud issues through the enhanced JQL endpoint of ``api_version``. Use ``nextPageToken`` from a previous response to retrieve the next page. Unlike the older search API, enhanced JQL is cursor-paginated. @@ -60,7 +60,7 @@ def enhanced_jql( params["fields"] = ",".join(fields) if isinstance(fields, (list, tuple, set)) else fields if expand is not None: params["expand"] = expand - return self.get(self.endpoint("search/jql", api_version=3), params=params) + return self.get(self.endpoint("search/jql"), params=params) def enhanced_jql_get_list_of_tickets( self, diff --git a/docs/jira_cloud.rst b/docs/jira_cloud.rst index d873a468c..4afcb52b1 100644 --- a/docs/jira_cloud.rst +++ b/docs/jira_cloud.rst @@ -36,8 +36,8 @@ Enhanced JQL search ------------------- Both ``JiraCloud`` and the legacy ``Jira(..., cloud=True)`` client provide -``enhanced_jql()``. The method always uses Jira Cloud's v3 -``/search/jql`` endpoint, regardless of the Core client's selected version. +``enhanced_jql()``. ``JiraCloud`` uses the ``/search/jql`` endpoint of its +``api_version`` (3 by default). The legacy client always uses the v3 endpoint. Pass the returned ``nextPageToken`` to fetch another page, or use ``enhanced_jql_get_list_of_tickets()`` to collect cursor-paginated results. diff --git a/tests/test_jira_cloud_clients.py b/tests/test_jira_cloud_clients.py index 586a2bd55..3f2c3b2da 100644 --- a/tests/test_jira_cloud_clients.py +++ b/tests/test_jira_cloud_clients.py @@ -82,7 +82,7 @@ def test_core_methods_honor_the_selected_v2_route(self): jira.get_issue("ABC-1") get.assert_called_once_with("rest/api/2/issue/ABC-1", params=None, data=None) - def test_core_client_supports_enhanced_jql_at_v3(self): + def test_core_client_enhanced_jql_uses_the_configured_api_version(self): jira = JiraCloud("https://example.atlassian.net", api_version=2) with patch.object(jira, "get", return_value={"issues": [], "isLast": True}) as get: @@ -95,7 +95,7 @@ def test_core_client_supports_enhanced_jql_at_v3(self): ) get.assert_called_once_with( - "rest/api/3/search/jql", + "rest/api/2/search/jql", params={ "jql": "project = EXAMPLE ORDER BY key DESC", "fields": "summary,description", @@ -105,6 +105,11 @@ def test_core_client_supports_enhanced_jql_at_v3(self): }, ) + default = JiraCloud("https://example.atlassian.net") + with patch.object(default, "get", return_value={"issues": [], "isLast": True}) as get: + default.enhanced_jql("project = EXAMPLE") + get.assert_called_once_with("rest/api/3/search/jql", params={"jql": "project = EXAMPLE", "fields": "*all"}) + def test_core_client_enhanced_jql_collects_cursor_pages(self): jira = JiraCloud("https://example.atlassian.net")