@@ -84,7 +84,12 @@ def _perform_jql_search(
84
84
f"Fetching Jira issues with JQL: { jql } , "
85
85
f"starting at { start } , max results: { max_results } "
86
86
)
87
- issues = jira_client .search_issues (
87
+
88
+ # Use custom search method to handle Atlassian's API breaking change
89
+ # The old /rest/api/{version}/search endpoint has been deprecated
90
+ # New endpoint is /rest/api/{version}/search/jql
91
+ issues = _custom_search_issues (
92
+ jira_client ,
88
93
jql_str = jql ,
89
94
startAt = start ,
90
95
maxResults = max_results ,
@@ -98,6 +103,67 @@ def _perform_jql_search(
98
103
raise RuntimeError (f"Found Jira object not of type Issue: { issue } " )
99
104
100
105
106
+ def _custom_search_issues (
107
+ jira_client : JIRA ,
108
+ jql_str : str ,
109
+ startAt : int = 0 ,
110
+ maxResults : int = 50 ,
111
+ fields : str | None = None ,
112
+ ) -> Iterable [Issue ]:
113
+ """
114
+ Simple fix for Atlassian's API breaking change.
115
+
116
+ The old /rest/api/{version}/search endpoint has been deprecated and removed.
117
+ New endpoint is /rest/api/{version}/search/jql
118
+
119
+ This is a minimal fix to resolve the immediate issue. For performance improvements,
120
+ see the upgrade instructions in JIRA_API_FIX_SUMMARY.md
121
+ """
122
+ if isinstance (fields , str ):
123
+ fields = fields .split ("," )
124
+ elif fields is None :
125
+ fields = ["*all" ]
126
+
127
+ # Build search parameters - keep the same interface for backwards compatibility
128
+ search_params = {
129
+ "jql" : jql_str ,
130
+ "startAt" : startAt ,
131
+ "maxResults" : maxResults ,
132
+ "fields" : fields ,
133
+ "validateQuery" : True ,
134
+ }
135
+
136
+ # Use the new JQL endpoint
137
+ url = f"{ jira_client .server_url } /rest/api/{ jira_client ._options .get ('rest_api_version' , '3' )} /search/jql"
138
+
139
+ # Make the request directly to the new endpoint
140
+ response = jira_client ._session .post (url , json = search_params )
141
+
142
+ if response .status_code == 410 :
143
+ # Fallback to old method if needed (though it should fail now)
144
+ logger .warning ("JQL endpoint returned 410, falling back to old search method" )
145
+ return jira_client .search_issues (
146
+ jql_str = jql_str ,
147
+ startAt = startAt ,
148
+ maxResults = maxResults ,
149
+ fields = fields ,
150
+ )
151
+
152
+ response .raise_for_status ()
153
+ data = response .json ()
154
+
155
+ # Convert the response to Issue objects
156
+ issues = []
157
+ for issue_data in data .get ("issues" , []):
158
+ issue = Issue (jira_client , issue_data )
159
+ # Ensure the issue has the necessary attributes
160
+ if not hasattr (issue , "key" ) and "key" in issue_data :
161
+ issue .key = issue_data ["key" ]
162
+ issues .append (issue )
163
+
164
+ return issues
165
+
166
+
101
167
def process_jira_issue (
102
168
jira_client : JIRA ,
103
169
issue : Issue ,
0 commit comments