From 10f817de5f2ce976e7d6eaa210d0e25fcd24e9e5 Mon Sep 17 00:00:00 2001 From: Reuven Harrison Date: Sun, 26 Apr 2026 22:40:38 +0300 Subject: [PATCH] feat(pr-comment): handle 409 github_app_not_installed gracefully When the service returns 409 with a github_app_not_installed code, parse the structured JSON body and surface a clear, actionable error: - A ::error:: workflow annotation with a title and the install URL. - A markdown setup checklist written to \$GITHUB_STEP_SUMMARY (visible on the workflow run page) telling the customer exactly what to do. Falls back to the existing generic-error behavior for any other non-2xx response. Pairs with oasdiff-service PR #175 which switches the App- not-installed response from HTTP 502 plain text to HTTP 409 + JSON. Co-Authored-By: Claude Opus 4.7 (1M context) --- pr-comment/entrypoint.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pr-comment/entrypoint.sh b/pr-comment/entrypoint.sh index 69e2ff2..c360549 100755 --- a/pr-comment/entrypoint.sh +++ b/pr-comment/entrypoint.sh @@ -114,6 +114,26 @@ if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then if [ -n "$report_url" ]; then echo "Review page: $report_url" fi +elif [ "$http_code" = "409" ] && [ "$(echo "$body" | jq -r '.code // empty' 2>/dev/null)" = "github_app_not_installed" ]; then + # The service returns 409 with a structured JSON body when the customer's + # repo does not have the oasdiff GitHub App installed. Surface a clear, + # actionable error to the workflow log and step summary. + err_owner=$(echo "$body" | jq -r '.owner') + err_repo=$(echo "$body" | jq -r '.repo') + install_url=$(echo "$body" | jq -r '.install_url') + echo "::error title=oasdiff GitHub App not installed::Install the App at ${install_url} on ${err_owner}/${err_repo} and re-run this workflow." + { + echo "### ❌ oasdiff GitHub App not installed" + echo "" + echo "The oasdiff GitHub App is not installed on **${err_owner}/${err_repo}**, so this workflow cannot post a PR comment or set commit statuses." + echo "" + echo "**Fix:**" + echo "" + echo "1. Visit [${install_url}](${install_url})" + echo "2. Click **Install** and select the \`${err_owner}/${err_repo}\` repository" + echo "3. Re-run this workflow" + } >> "$GITHUB_STEP_SUMMARY" + exit 1 else echo "ERROR: oasdiff-service returned HTTP $http_code" >&2 echo "$body" >&2