Skip to content

Commit 37bf9ff

Browse files
feat(pr-comment): handle 409 github_app_not_installed gracefully (#105)
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) <noreply@anthropic.com>
1 parent 6ef3c27 commit 37bf9ff

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

pr-comment/entrypoint.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,26 @@ if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
114114
if [ -n "$report_url" ]; then
115115
echo "Review page: $report_url"
116116
fi
117+
elif [ "$http_code" = "409" ] && [ "$(echo "$body" | jq -r '.code // empty' 2>/dev/null)" = "github_app_not_installed" ]; then
118+
# The service returns 409 with a structured JSON body when the customer's
119+
# repo does not have the oasdiff GitHub App installed. Surface a clear,
120+
# actionable error to the workflow log and step summary.
121+
err_owner=$(echo "$body" | jq -r '.owner')
122+
err_repo=$(echo "$body" | jq -r '.repo')
123+
install_url=$(echo "$body" | jq -r '.install_url')
124+
echo "::error title=oasdiff GitHub App not installed::Install the App at ${install_url} on ${err_owner}/${err_repo} and re-run this workflow."
125+
{
126+
echo "### ❌ oasdiff GitHub App not installed"
127+
echo ""
128+
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."
129+
echo ""
130+
echo "**Fix:**"
131+
echo ""
132+
echo "1. Visit [${install_url}](${install_url})"
133+
echo "2. Click **Install** and select the \`${err_owner}/${err_repo}\` repository"
134+
echo "3. Re-run this workflow"
135+
} >> "$GITHUB_STEP_SUMMARY"
136+
exit 1
117137
else
118138
echo "ERROR: oasdiff-service returned HTTP $http_code" >&2
119139
echo "$body" >&2

0 commit comments

Comments
 (0)