Skip to content

Commit ae05e4c

Browse files
committed
fix(jira): use rest v3 api for JQL search
1 parent 153f13e commit ae05e4c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/issue-tracker/jira/Jira.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ const isCreateSubTask = (
7171
return 'parent' in createIssue;
7272
};
7373

74-
// Using Jira REST API v2 (https://developer.atlassian.com/cloud/jira/platform/rest/v2)
74+
// Using Jira REST API v2 for most endpoints, v3 for search (https://developer.atlassian.com/cloud/jira/platform/rest/)
75+
// TODO Use v3 for all endpoints
7576
export class Jira implements Tracker {
7677
private client: HttpClient;
78+
private searchClient: HttpClient;
7779
private config: TrackerConfig;
7880
private messenger: Messenger;
7981
private readonly debug: Debugger;
@@ -82,12 +84,18 @@ export class Jira implements Tracker {
8284
constructor(config: TrackerConfig, messenger: Messenger) {
8385
this.config = config;
8486
this.messenger = messenger;
85-
// TODO Add a new client for agile API https://developer.atlassian.com/cloud/jira/software/rest/
87+
// Main client uses API v2 for compatibility
8688
this.client = new HttpClient({
8789
allowConcurrentRequests: false,
8890
auth: { password: config.user.token, username: config.user.login },
8991
root: `${config.root}/rest/api/2`,
9092
});
93+
// Separate client for v3 search endpoints (required due to API deprecation)
94+
this.searchClient = new HttpClient({
95+
allowConcurrentRequests: false,
96+
auth: { password: config.user.token, username: config.user.login },
97+
root: `${config.root}/rest/api/3`,
98+
});
9199
this.debug = debug.extend('jira');
92100
}
93101

@@ -296,6 +304,7 @@ export class Jira implements Tracker {
296304
switchMap(([user, status]: [User, Partial<Record<IssueStatus, JiraIssueStatus[]>>]) => {
297305
const qs = {
298306
expand: 'transitions, renderedFields',
307+
fields: '*all',
299308
jql: `assignee=${user.accountId} AND status IN (${[
300309
IssueStatus.BACKLOG,
301310
IssueStatus.SELECTED_FOR_DEVELOPMENT,
@@ -305,7 +314,7 @@ export class Jira implements Tracker {
305314
.filter((s) => s !== undefined)
306315
.join(',')}) ORDER BY CREATED DESC`,
307316
};
308-
return this.client.get<{ issues: JiraIssue[] }>(`/search`, {
317+
return this.searchClient.get<{ issues: JiraIssue[] }>(`/search/jql`, {
309318
qs: qs,
310319
});
311320
}),

test/issue-tracker/Jira.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ describe('jira', () => {
120120
{
121121
"qs": {
122122
"expand": "transitions, renderedFields",
123+
"fields": "*all",
123124
"jql": "assignee=Jerry.Rosenbaum AND status IN ('backlog','To do','to do') ORDER BY CREATED DESC",
124125
},
125126
}

0 commit comments

Comments
 (0)