Skip to content

Commit 9c0543e

Browse files
Phlogistiqueclaudegithub-actions
authored
Abort the resume when label or comment reads fail (#50)
`pr_has_conflict_label` swallowed gh failures as "no label", so a transient API error made the resume silently skip a labeled PR. Worse, a failed comments fetch in `read_state_marker` read as "no marker", which made the caller *abandon* the resume and drop the conflict label for good — a dead end. Both now abort the run instead; the label stays on, so the next push retries. Stacked on #45; #51 builds on this. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JHvKryT4QUpHYdNq9YEQxX --- _Generated by [Claude Code](https://claude.ai/code/session_01JHvKryT4QUpHYdNq9YEQxX)_ --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: github-actions <github-actions@github.com>
1 parent 0386ed1 commit 9c0543e

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

update-pr-stack.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ format_state_marker() {
4343
# Echoes the most recent state-marker line found in our PR comments, or nothing.
4444
read_state_marker() {
4545
local PR_NUMBER="$1"
46-
gh pr view "$PR_NUMBER" --json comments --jq '.comments[].body' 2>/dev/null \
47-
| { grep -F "$STATE_MARKER_PREFIX" || true; } | tail -n1
46+
local BODIES
47+
if ! BODIES=$(gh pr view "$PR_NUMBER" --json comments --jq '.comments[].body'); then
48+
echo "Error: could not read comments of PR #$PR_NUMBER" >&2
49+
exit 1
50+
fi
51+
{ grep -F "$STATE_MARKER_PREFIX" <<<"$BODIES" || true; } | tail -n1
4852
}
4953

5054
# Args: a marker line. Echoes "base target squash".
@@ -231,11 +235,14 @@ See $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID"
231235
return 0
232236
}
233237

234-
# Check if a PR has the conflict resolution label
238+
# Check if a PR has the conflict resolution label.
235239
pr_has_conflict_label() {
236240
local PR_NUMBER="$1"
237241
local LABELS
238-
LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name' 2>/dev/null || echo "")
242+
if ! LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name'); then
243+
echo "Error: could not read labels of PR #$PR_NUMBER" >&2
244+
exit 1
245+
fi
239246
echo "$LABELS" | grep -q "^${CONFLICT_LABEL}$"
240247
}
241248

0 commit comments

Comments
 (0)