Skip to content

Add error handling for GitHub API job URL fetching in build-artifact workflow#185

Merged
printminion-co merged 2 commits intomk/dev/jfrog_add_workflow_infofrom
copilot/sub-pr-184
Jan 15, 2026
Merged

Add error handling for GitHub API job URL fetching in build-artifact workflow#185
printminion-co merged 2 commits intomk/dev/jfrog_add_workflow_infofrom
copilot/sub-pr-184

Conversation

Copy link

Copilot AI commented Jan 15, 2026

Summary

Addresses review feedback from PR #184 by adding robust error handling to GitHub API calls that fetch job URLs for JFrog artifact metadata. Previously, API failures or invalid responses would silently result in empty job URLs propagating to artifact properties.

Error handling added:

  • HTTP status code validation - fails workflow if API returns non-200 response
  • Empty/null URL validation - fails workflow if jq cannot extract job URL from response
  • Debug output - logs response body when extraction fails for troubleshooting

Affected locations:

  • build-external-apps job (lines 309-330) - fetches URL for matrix build jobs
  • Push to artifactory job (lines 722-743) - fetches URL for main artifact upload

Both locations now use consistent error handling pattern:

API_RESPONSE=$(curl -s -w "\n%{http_code}" -H "Authorization: Bearer ${{ github.token }}" \
  -H "Accept: application/vnd.github+json" \
  "https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs")

HTTP_CODE=$(echo "$API_RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$API_RESPONSE" | sed '$d')

if [ "$HTTP_CODE" != "200" ]; then
  echo "❌ ERROR: GitHub API request failed with HTTP code $HTTP_CODE"
  exit 1
fi

JOB_URL=$(echo "$RESPONSE_BODY" | jq -r '.jobs[] | select(.name == "job-name") | .html_url')

if [ -z "$JOB_URL" ] || [ "$JOB_URL" = "null" ]; then
  echo "❌ ERROR: Failed to extract job URL from API response"
  echo "Response body: $RESPONSE_BODY"
  exit 1
fi

TODO

  • N/A

Checklist


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… workflow

Co-authored-by: printminion-co <145785698+printminion-co@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance artifact upload process with richer metadata Add error handling for GitHub API job URL fetching in build-artifact workflow Jan 15, 2026
@printminion-co printminion-co marked this pull request as ready for review January 15, 2026 16:02
Copilot AI requested a review from printminion-co January 15, 2026 16:02
@printminion-co printminion-co merged commit 1266c74 into mk/dev/jfrog_add_workflow_info Jan 15, 2026
1 check failed
@printminion-co printminion-co deleted the copilot/sub-pr-184 branch January 15, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants