From 0554310db81a0be48be86e5e6ba45d9bee409e96 Mon Sep 17 00:00:00 2001 From: James Hall Date: Mon, 8 Jun 2026 00:57:42 +0100 Subject: [PATCH 1/2] ci: fail safe on triage comment-lookup error (treat as re-triage, no re-label) --- .github/workflows/issue-triage.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml index 218ab3e..1643e8c 100644 --- a/.github/workflows/issue-triage.yml +++ b/.github/workflows/issue-triage.yml @@ -139,9 +139,20 @@ jobs: # find our previous triage comment (if any). its presence means this issue # was already triaged, so a re-run refreshes the comment but leaves labels # and fields alone - never clobbering a maintainer's later edits. - CID=$(gh api "repos/$REPO/issues/$NUM/comments" --paginate \ - --jq "[.[] | select(.body | contains(\"$MARKER\")) | .id] | last // empty" 2>/dev/null || true) - FIRST_TRIAGE=true; [ -n "$CID" ] && FIRST_TRIAGE=false + # + # distinguish "lookup succeeded, no marker" (genuinely first triage) from + # "lookup failed" (transient api/auth/network error). on failure we must NOT + # default to first-triage, or a flaky api call could re-apply labels over a + # maintainer's edits - so fail safe: assume re-triage (no label/field changes). + if CID_RAW=$(gh api "repos/$REPO/issues/$NUM/comments" --paginate \ + --jq "[.[] | select(.body | contains(\"$MARKER\")) | .id] | last // empty" 2>/dev/null); then + # --paginate emits one (possibly empty) line per page; keep the matched id. + CID=$(printf '%s\n' "$CID_RAW" | grep -E '^[0-9]+$' | tail -1 || true) + FIRST_TRIAGE=true; [ -n "$CID" ] && FIRST_TRIAGE=false + else + echo "comment lookup failed - treating as re-triage so labels/fields aren't clobbered" + CID=""; FIRST_TRIAGE=false + fi # prefer the whole response if it already parses as json (expected case: # the model is asked for one line of minified json). otherwise strip any From 0ca4db7e4a48ad59aa0b72ee221c30b66ffea79d Mon Sep 17 00:00:00 2001 From: James Hall Date: Mon, 8 Jun 2026 01:00:31 +0100 Subject: [PATCH 2/2] ci: surface gh stderr on triage comment lookup for diagnosability --- .github/workflows/issue-triage.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml index 1643e8c..0c8973a 100644 --- a/.github/workflows/issue-triage.yml +++ b/.github/workflows/issue-triage.yml @@ -144,8 +144,10 @@ jobs: # "lookup failed" (transient api/auth/network error). on failure we must NOT # default to first-triage, or a flaky api call could re-apply labels over a # maintainer's edits - so fail safe: assume re-triage (no label/field changes). + # stderr is left visible on purpose: the if/else handles failure, so any + # gh error (auth/scope/rate/network) should show up in the run log. if CID_RAW=$(gh api "repos/$REPO/issues/$NUM/comments" --paginate \ - --jq "[.[] | select(.body | contains(\"$MARKER\")) | .id] | last // empty" 2>/dev/null); then + --jq "[.[] | select(.body | contains(\"$MARKER\")) | .id] | last // empty"); then # --paginate emits one (possibly empty) line per page; keep the matched id. CID=$(printf '%s\n' "$CID_RAW" | grep -E '^[0-9]+$' | tail -1 || true) FIRST_TRIAGE=true; [ -n "$CID" ] && FIRST_TRIAGE=false