From 330176a55bfef698809d5dc655206e2393facb50 Mon Sep 17 00:00:00 2001 From: maira-samtek <120603218+maira-samtek@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:42:42 -0500 Subject: [PATCH] Fix Watchers and Linking Issue (#62) * handled watchers * handled watchers * handled watchers --- dist/index.js | 13 ++++++++++--- src/libs/jira-lib.ts | 23 +++++++++++++++-------- src/macfc-security-hub-sync.ts | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/dist/index.js b/dist/index.js index c5b2ac2..0dcd910 100644 --- a/dist/index.js +++ b/dist/index.js @@ -60089,8 +60089,15 @@ class Jira { // Construct the webUrl for the new issue newIssue['webUrl'] = `${this.jiraBaseURI}/browse/${newIssue.key}`; await this.removeCurrentUserAsWatcher(newIssue.key); - if (this.jiraWatchers) { - await Promise.all(this.jiraWatchers.map((watcher) => this.addUserAsWatcher(newIssue.key, watcher, this.jiraBaseURI.includes('atlassian') == false))); + if (this.jiraWatchers && this.jiraWatchers.length >= 1) { + try { + await Promise.all(this.jiraWatchers.map((watcher) => watcher && + this.addUserAsWatcher(newIssue.key, watcher, this.jiraBaseURI.includes('atlassian') == false))); + } + catch (error) { + console.log('Error: could not add watchers', this.jiraWatchers); + return newIssue; + } } return newIssue; } @@ -60829,7 +60836,7 @@ class SecurityHubJiraSync { } // Validate the extracted region if (!isAwsRegion(region)) { - console.error(`Invalid AWS region: ${region}`); + //console.error(`Invalid AWS region: ${region}`) region = 'us-east-1'; // Fallback to default region } // Encode the findingId and operator for URL diff --git a/src/libs/jira-lib.ts b/src/libs/jira-lib.ts index 6e51be4..a0bb7cf 100644 --- a/src/libs/jira-lib.ts +++ b/src/libs/jira-lib.ts @@ -459,16 +459,23 @@ export class Jira { // Construct the webUrl for the new issue newIssue['webUrl'] = `${this.jiraBaseURI}/browse/${newIssue.key}` await this.removeCurrentUserAsWatcher(newIssue.key) - if (this.jiraWatchers) { - await Promise.all( - this.jiraWatchers.map((watcher: string) => - this.addUserAsWatcher( - newIssue.key, - watcher, - this.jiraBaseURI.includes('atlassian') == false + if (this.jiraWatchers && this.jiraWatchers.length >= 1) { + try { + await Promise.all( + this.jiraWatchers.map( + (watcher: string) => + watcher && + this.addUserAsWatcher( + newIssue.key, + watcher, + this.jiraBaseURI.includes('atlassian') == false + ) ) ) - ) + } catch (error: unknown) { + console.log('Error: could not add watchers', this.jiraWatchers) + return newIssue + } } return newIssue } catch (error: unknown) { diff --git a/src/macfc-security-hub-sync.ts b/src/macfc-security-hub-sync.ts index e1a1880..ff8366e 100644 --- a/src/macfc-security-hub-sync.ts +++ b/src/macfc-security-hub-sync.ts @@ -446,7 +446,7 @@ export class SecurityHubJiraSync { // Validate the extracted region if (!isAwsRegion(region)) { - console.error(`Invalid AWS region: ${region}`) + //console.error(`Invalid AWS region: ${region}`) region = 'us-east-1' // Fallback to default region }