From 52db7c220c243b2b7dae2cc1c7a776c67a0998f1 Mon Sep 17 00:00:00 2001 From: Robert M1 <50460704+githubrobbi@users.noreply.github.com> Date: Sun, 19 Jul 2026 18:24:08 -0700 Subject: [PATCH] fix(ci): don't let a transient GitHub API error fail the commitlint gate gh api's stdout on a 5xx error is its JSON error body, but the command still exits non-zero; the existing `|| true` swallowed the exit code while EXISTING_ID still captured that JSON text as if it were a real comment id. The subsequent DELETE/PATCH call then crashed on the garbage URL, failing this *required* gate for a reason unrelated to title conformance (release PR #564 hit this: title conformed, the stale-comment-cleanup lookup 503'd, and the whole job died). Validate EXISTING_ID is purely numeric before trusting it; anything else (including a JSON error blob) is treated as "no existing comment" so the conformance result stands on its own. --- .github/workflows/commitlint.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index 6af627355..7b5dd253a 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -196,11 +196,24 @@ jobs: # comments endpoint (PR comments live there) and jq-filter # by marker presence. `head -1` defends against the # (impossible-but-cheap-to-guard) double-managed-comment case. + # + # A transient GitHub API error (e.g. a 503) makes `gh api` + # print its JSON error body to stdout while still exiting + # non-zero; the `|| true` swallows the exit code but not + # that body, so EXISTING_ID could otherwise become garbage + # text instead of a real comment id — which then crashes the + # DELETE/PATCH call below and fails this *required* gate for + # a reason unrelated to title conformance. Validate the + # result is purely numeric (a real id always is) and treat + # anything else as "no existing comment found". EXISTING_ID=$( gh api --paginate "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \ --jq ".[] | select(.body | contains(\"${COMMENT_MARKER}\")) | .id" \ | head -1 || true ) + if ! [[ "${EXISTING_ID}" =~ ^[0-9]+$ ]]; then + EXISTING_ID="" + fi if echo "$TITLE" | grep -qE "$PATTERN"; then # ── Conforming title ───────────────────────────────────