From 9856d5ebe13efa716e401e217a7e65a3ee186dc4 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 13:28:17 +0000 Subject: [PATCH 1/9] ci: Fix ipa metrics release job --- .github/workflows/release-IPA-metrics.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-IPA-metrics.yml b/.github/workflows/release-IPA-metrics.yml index 68f940837c..d9a82df39d 100644 --- a/.github/workflows/release-IPA-metrics.yml +++ b/.github/workflows/release-IPA-metrics.yml @@ -65,7 +65,7 @@ jobs: working-directory: ${{ github.workspace }} - name: Upload OAS files as artifacts - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f with: name: oas-files path: | @@ -81,6 +81,14 @@ jobs: node runMetricCollection.js "${{ github.workspace }}/v2-filtered.json" echo "WARNING_COUNT=$(cat ../outputs/warning-count.txt)" >> "$GITHUB_ENV" + - name: Upload Warning Violations as Artifact + if: always() + uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f + with: + name: warning-violations + path: tools/spectral/ipa/metrics/outputs/warning-violations.json + retention-days: 1 + - name: aws configure uses: aws-actions/configure-aws-credentials@v5 with: From 5c28e47fdec1199ed6ae3893c0321c4e6d138892 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 14:13:02 +0000 Subject: [PATCH 2/9] fix --- .github/scripts/handle_warning_violations.sh | 30 ++++++++----------- .github/workflows/release-IPA-metrics.yml | 1 - .../metrics/metricCollection.test.js | 1 + .../spectral/ipa/metrics/metricCollection.js | 1 + 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index 8fd0018290..fb055f91a1 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -11,16 +11,21 @@ fi VIOLATION_DETAILS="" if [ -f "tools/spectral/ipa/metrics/outputs/warning-violations.json" ]; then VIOLATION_DETAILS=$(jq -r ' - group_by(.code) | - map("• " + .[0].code + " (" + (length | tostring) + " violations)") | - join("\n") + group_by(.code) | + map( + "• " + .[0].code + " (" + (length | tostring) + " violations):\n" + + (map(" - " + .component_id) | join("\n")) + ) | + join("\n\n") ' tools/spectral/ipa/metrics/outputs/warning-violations.json) fi # Check if warning ticket already exists echo "Check if a jira ticket already exists." -EXISTING_TICKET=$(curl -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ - "https://jira.mongodb.org/rest/api/2/search?jql=project=CLOUDP AND summary~'Warning-level IPA violations' AND status!=Done" \ +JQL_QUERY="project=CLOUDP AND summary~'Warning-level IPA violations' AND status!=Done" +EXISTING_TICKET=$(curl -G -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ + --data-urlencode "jql=${JQL_QUERY}" \ + "https://jira.mongodb.org/rest/api/2/search" \ | jq -r '.issues[0].key // empty') if [ -n "${EXISTING_TICKET}" ]; then @@ -57,22 +62,13 @@ TICKET_RESPONSE=$(curl -X POST -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ TICKET_KEY=$(echo "${TICKET_RESPONSE}" | jq -r '.key') if [ "${TICKET_KEY}" != "null" ]; then echo "Created Jira ticket: ${TICKET_KEY}." - # Create summary for Slack - echo "Creating Slack Summary with VIOLATION_DETAILS: ${VIOLATION_DETAILS}..." - SLACK_SUMMARY="" - if [ -n "${VIOLATION_DETAILS}" ]; then - SLACK_SUMMARY=$(echo "${VIOLATION_DETAILS}" | head -3) - if [ "$(echo "${VIOLATION_DETAILS}" | wc -l)" -gt 3 ]; then - SLACK_SUMMARY="${SLACK_SUMMARY}\n... and more" - fi - fi echo "Send Slack notification..." - # Send Slack notification with violation summary + # Send Slack notification with link to Jira ticket for details SLACK_MESSAGE="Warning-level IPA violations found (${WARNING_COUNT} violations) (${SLACK_ONCALL_USER}). -Jira ticket: https://jira.mongodb.org/browse/${TICKET_KEY}" - +See Jira ticket for details: https://jira.mongodb.org/browse/${TICKET_KEY}" + curl -X POST -H "Authorization: Bearer ${SLACK_BEARER_TOKEN}" \ -H "Content-type: application/json" \ --data "{\"channel\":\"${SLACK_CHANNEL_ID}\",\"text\":\"${SLACK_MESSAGE}\"}" \ diff --git a/.github/workflows/release-IPA-metrics.yml b/.github/workflows/release-IPA-metrics.yml index d9a82df39d..b55cc06992 100644 --- a/.github/workflows/release-IPA-metrics.yml +++ b/.github/workflows/release-IPA-metrics.yml @@ -82,7 +82,6 @@ jobs: echo "WARNING_COUNT=$(cat ../outputs/warning-count.txt)" >> "$GITHUB_ENV" - name: Upload Warning Violations as Artifact - if: always() uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f with: name: warning-violations diff --git a/tools/spectral/ipa/__tests__/metrics/metricCollection.test.js b/tools/spectral/ipa/__tests__/metrics/metricCollection.test.js index 37ffdc1af7..6e67c17b4d 100644 --- a/tools/spectral/ipa/__tests__/metrics/metricCollection.test.js +++ b/tools/spectral/ipa/__tests__/metrics/metricCollection.test.js @@ -45,6 +45,7 @@ describe('tools/spectral/ipa/metrics/metricCollection.js runMetricCollectionJob' const violations = [ { code: 'xgen-IPA-104-valid-operation-id-warn', + component_id: 'paths./api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}.get', }, ]; expect(results.warnings.violations).toEqual(violations); diff --git a/tools/spectral/ipa/metrics/metricCollection.js b/tools/spectral/ipa/metrics/metricCollection.js index 0a8466453b..158836c71e 100644 --- a/tools/spectral/ipa/metrics/metricCollection.js +++ b/tools/spectral/ipa/metrics/metricCollection.js @@ -38,6 +38,7 @@ export async function runMetricCollectionJob( const processedWarnings = warningViolations.map((violation) => ({ code: violation.ipa_rule, + component_id: violation.component_id, })); console.log(`Found ${warningViolations.length} warning-level violations`); From 02cb7be4ac2fa4e611cb49aea0dcda13088080eb Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 14:19:00 +0000 Subject: [PATCH 3/9] fix --- .github/scripts/handle_warning_violations.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index fb055f91a1..2bc626e330 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -22,7 +22,7 @@ fi # Check if warning ticket already exists echo "Check if a jira ticket already exists." -JQL_QUERY="project=CLOUDP AND summary~'Warning-level IPA violations' AND status!=Done" +JQL_QUERY="project=CLOUDP AND summary~'Warning-level IPA violations' AND status NOT IN (Done, Resolved, Closed)" EXISTING_TICKET=$(curl -G -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ --data-urlencode "jql=${JQL_QUERY}" \ "https://jira.mongodb.org/rest/api/2/search" \ From 1cc3f1dd5934c364db0636ea68b9b5e2349cf03c Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 14:24:00 +0000 Subject: [PATCH 4/9] fix --- .github/scripts/handle_warning_violations.sh | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index 2bc626e330..827a12d78e 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -45,18 +45,22 @@ ${VIOLATION_DETAILS} Total violations: ${WARNING_COUNT}" echo "Jira ticket does not exists. Creating..." -# Create new Jira ticket -TICKET_RESPONSE=$(curl -X POST -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ - -H "Content-Type: application/json" \ - -d "{ - \"fields\": { - \"project\": {\"key\": \"CLOUDP\"}, - \"summary\": \"Warning-level IPA violations found\", - \"description\": \"${DESCRIPTION}\", - \"issuetype\": {\"name\": \"Task\"}, - \"assignee\": {\"id\": \"${TEAM_ID}\"} +# Create new Jira ticket with properly escaped JSON +TICKET_RESPONSE=$(jq -n \ + --arg summary "Warning-level IPA violations found" \ + --arg description "$DESCRIPTION" \ + --arg teamId "$TEAM_ID" \ + '{ + fields: { + project: {key: "CLOUDP"}, + summary: $summary, + description: $description, + issuetype: {name: "Task"}, + assignee: {id: $teamId} } - }" \ + }' | curl -X POST -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ + -H "Content-Type: application/json" \ + -d @- \ "https://jira.mongodb.org/rest/api/2/issue/") TICKET_KEY=$(echo "${TICKET_RESPONSE}" | jq -r '.key') From 3a0f5404f3fd68d0fa803e1874ba92344b960e5b Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 14:27:33 +0000 Subject: [PATCH 5/9] logging --- .github/scripts/handle_warning_violations.sh | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index 827a12d78e..f89fcfda3e 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -44,9 +44,9 @@ ${VIOLATION_DETAILS} Total violations: ${WARNING_COUNT}" -echo "Jira ticket does not exists. Creating..." +echo "Jira ticket does not exist. Creating..." # Create new Jira ticket with properly escaped JSON -TICKET_RESPONSE=$(jq -n \ +TICKET_PAYLOAD=$(jq -n \ --arg summary "Warning-level IPA violations found" \ --arg description "$DESCRIPTION" \ --arg teamId "$TEAM_ID" \ @@ -58,13 +58,25 @@ TICKET_RESPONSE=$(jq -n \ issuetype: {name: "Task"}, assignee: {id: $teamId} } - }' | curl -X POST -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ + }') + +echo "Jira ticket payload:" +echo "${TICKET_PAYLOAD}" + +TICKET_RESPONSE=$(echo "${TICKET_PAYLOAD}" | curl -X POST -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ -H "Content-Type: application/json" \ -d @- \ + -w "\nHTTP_STATUS:%{http_code}" \ "https://jira.mongodb.org/rest/api/2/issue/") -TICKET_KEY=$(echo "${TICKET_RESPONSE}" | jq -r '.key') -if [ "${TICKET_KEY}" != "null" ]; then +echo "Jira API response:" +echo "${TICKET_RESPONSE}" + +HTTP_STATUS=$(echo "${TICKET_RESPONSE}" | grep "HTTP_STATUS:" | cut -d: -f2) +TICKET_BODY=$(echo "${TICKET_RESPONSE}" | sed '/HTTP_STATUS:/d') + +TICKET_KEY=$(echo "${TICKET_BODY}" | jq -r '.key // empty') +if [ -n "${TICKET_KEY}" ] && [ "${TICKET_KEY}" != "null" ]; then echo "Created Jira ticket: ${TICKET_KEY}." echo "Send Slack notification..." @@ -79,5 +91,11 @@ See Jira ticket for details: https://jira.mongodb.org/browse/${TICKET_KEY}" https://slack.com/api/chat.postMessage else echo "Failed to create Jira ticket" + echo "HTTP Status: ${HTTP_STATUS}" + echo "Response body: ${TICKET_BODY}" + + # Try to extract error message from Jira response + ERROR_MESSAGES=$(echo "${TICKET_BODY}" | jq -r '.errorMessages[]? // .errors? // "No error details available"' 2>/dev/null || echo "Could not parse error response") + echo "Error details: ${ERROR_MESSAGES}" exit 1 fi From 6a16aa46c4448554b095dfda72095631f0ebd6e5 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 14:36:16 +0000 Subject: [PATCH 6/9] fix --- .github/scripts/handle_warning_violations.sh | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index f89fcfda3e..f4eb03fdec 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -45,18 +45,19 @@ ${VIOLATION_DETAILS} Total violations: ${WARNING_COUNT}" echo "Jira ticket does not exist. Creating..." -# Create new Jira ticket with properly escaped JSON +# Create new Jira ticket with properly escaped JSON (matching create_jira_ticket.sh format) TICKET_PAYLOAD=$(jq -n \ --arg summary "Warning-level IPA violations found" \ --arg description "$DESCRIPTION" \ --arg teamId "$TEAM_ID" \ '{ fields: { - project: {key: "CLOUDP"}, + project: {id: "10984"}, summary: $summary, description: $description, - issuetype: {name: "Task"}, - assignee: {id: $teamId} + issuetype: {id: "12"}, + customfield_12751: [{id: $teamId}], + components: [{id: "35986"}] } }') @@ -91,10 +92,6 @@ See Jira ticket for details: https://jira.mongodb.org/browse/${TICKET_KEY}" https://slack.com/api/chat.postMessage else echo "Failed to create Jira ticket" - echo "HTTP Status: ${HTTP_STATUS}" - echo "Response body: ${TICKET_BODY}" - - # Try to extract error message from Jira response ERROR_MESSAGES=$(echo "${TICKET_BODY}" | jq -r '.errorMessages[]? // .errors? // "No error details available"' 2>/dev/null || echo "Could not parse error response") echo "Error details: ${ERROR_MESSAGES}" exit 1 From d822c8298c3b2366fcb21d0cbc4b95451ea980da Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 14:47:46 +0000 Subject: [PATCH 7/9] fix --- .github/scripts/handle_warning_violations.sh | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index f4eb03fdec..e5ab7b0be7 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -86,10 +86,28 @@ if [ -n "${TICKET_KEY}" ] && [ "${TICKET_KEY}" != "null" ]; then See Jira ticket for details: https://jira.mongodb.org/browse/${TICKET_KEY}" - curl -X POST -H "Authorization: Bearer ${SLACK_BEARER_TOKEN}" \ + SLACK_RESPONSE=$(curl -X POST -H "Authorization: Bearer ${SLACK_BEARER_TOKEN}" \ -H "Content-type: application/json" \ --data "{\"channel\":\"${SLACK_CHANNEL_ID}\",\"text\":\"${SLACK_MESSAGE}\"}" \ - https://slack.com/api/chat.postMessage + https://slack.com/api/chat.postMessage) + + echo "Slack API response: ${SLACK_RESPONSE}" + + SLACK_OK=$(echo "${SLACK_RESPONSE}" | jq -r '.ok') + if [ "${SLACK_OK}" != "true" ]; then + SLACK_ERROR=$(echo "${SLACK_RESPONSE}" | jq -r '.error') + echo "Warning: Failed to send Slack notification. Error: ${SLACK_ERROR}" + + if [ "${SLACK_ERROR}" == "not_in_channel" ]; then + echo "The Slack bot is not a member of channel ${SLACK_CHANNEL_ID}." + echo "Please invite the bot to the channel or update SLACK_CHANNEL_ID." + fi + + # Don't fail the script - Jira ticket was created successfully + echo "Continuing despite Slack notification failure..." + else + echo "Slack notification sent successfully." + fi else echo "Failed to create Jira ticket" ERROR_MESSAGES=$(echo "${TICKET_BODY}" | jq -r '.errorMessages[]? // .errors? // "No error details available"' 2>/dev/null || echo "Could not parse error response") From c10186cc71abeb987a70f0244b849f956d212de6 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 14:54:35 +0000 Subject: [PATCH 8/9] shellcheck fix --- .github/scripts/handle_warning_violations.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index e5ab7b0be7..0e41fcb916 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -73,9 +73,6 @@ TICKET_RESPONSE=$(echo "${TICKET_PAYLOAD}" | curl -X POST -H "Authorization: Bea echo "Jira API response:" echo "${TICKET_RESPONSE}" -HTTP_STATUS=$(echo "${TICKET_RESPONSE}" | grep "HTTP_STATUS:" | cut -d: -f2) -TICKET_BODY=$(echo "${TICKET_RESPONSE}" | sed '/HTTP_STATUS:/d') - TICKET_KEY=$(echo "${TICKET_BODY}" | jq -r '.key // empty') if [ -n "${TICKET_KEY}" ] && [ "${TICKET_KEY}" != "null" ]; then echo "Created Jira ticket: ${TICKET_KEY}." From 8266f6a6da030becfb371f7affeaa57a6bf838d5 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Thu, 5 Feb 2026 15:06:51 +0000 Subject: [PATCH 9/9] script fix --- .github/scripts/handle_warning_violations.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/scripts/handle_warning_violations.sh b/.github/scripts/handle_warning_violations.sh index 0e41fcb916..48a91c3b76 100755 --- a/.github/scripts/handle_warning_violations.sh +++ b/.github/scripts/handle_warning_violations.sh @@ -67,13 +67,12 @@ echo "${TICKET_PAYLOAD}" TICKET_RESPONSE=$(echo "${TICKET_PAYLOAD}" | curl -X POST -H "Authorization: Bearer ${JIRA_API_TOKEN}" \ -H "Content-Type: application/json" \ -d @- \ - -w "\nHTTP_STATUS:%{http_code}" \ "https://jira.mongodb.org/rest/api/2/issue/") echo "Jira API response:" echo "${TICKET_RESPONSE}" -TICKET_KEY=$(echo "${TICKET_BODY}" | jq -r '.key // empty') +TICKET_KEY=$(echo "${TICKET_RESPONSE}" | jq -r '.key // empty') if [ -n "${TICKET_KEY}" ] && [ "${TICKET_KEY}" != "null" ]; then echo "Created Jira ticket: ${TICKET_KEY}." @@ -107,7 +106,8 @@ See Jira ticket for details: https://jira.mongodb.org/browse/${TICKET_KEY}" fi else echo "Failed to create Jira ticket" - ERROR_MESSAGES=$(echo "${TICKET_BODY}" | jq -r '.errorMessages[]? // .errors? // "No error details available"' 2>/dev/null || echo "Could not parse error response") + echo "Response: ${TICKET_RESPONSE}" + ERROR_MESSAGES=$(echo "${TICKET_RESPONSE}" | jq -r '.errorMessages[]? // .errors? // "No error details available"' 2>/dev/null || echo "Could not parse error response") echo "Error details: ${ERROR_MESSAGES}" exit 1 fi