Skip to content

Commit

Permalink
forward warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
matejdro committed Nov 9, 2023
1 parent bb08701 commit 458afd5
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions libs/src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,23 @@ export async function queryJiraTickets(jira: JiraApi): Promise<JiraTicket[]> {
let response: SearchResponse
core.info(`JQL: "${jql}"`)
do {
// @ts-ignore
var jsonResponse = await jira.searchJira(jql, {startAt: tickets.length, validateQuery: "warn"});
core.info(`Total Json: "${JSON.stringify(jsonResponse)}"`)
response = jsonResponse as SearchResponse
// @ts-expect-error
// Jira types do not have validateQuery here, so we must use @ts-ignore
const rawResponse = await jira.searchJira(jql, { startAt: tickets.length, validateQuery: 'warn' })
const warnings: string[] = rawResponse.warningMessages ?? []

for (const warning of warnings) {
if (warning.includes('An issue with key')) {
// This warning just means that we did not find desired issue. User might have just misstyped issue key.
// Forward it as warning
core.warning(warning)
} else {
throw Error(warning)
}
}

core.info(`Total Json: "${JSON.stringify(rawResponse)}"`)
response = rawResponse as SearchResponse
tickets.push(...response.issues)
} while (tickets.length < response.total)

Expand Down

0 comments on commit 458afd5

Please sign in to comment.