Fix check-requirements crash when PR has no issue references#15
Conversation
When a PR body contains no issue numbers, the grep -v '^$' pipeline exits with code 1 (no matches). Under bash -e, this kills the script before it reaches the if block that handles the empty-issues case. Add || true to both instances so the script continues to the requirements-not-met path instead of crashing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a GitHub Actions workflow failure in the PR requirements triage job when a PR body contains no issue references, by preventing an expected “no matches” grep exit code from aborting the step under bash -e / pipefail.
Changes:
- Prevent
ISSUE_NUMBERScollection from exiting the step whengrep -v '^$'has no matches (empty input). - Apply the same fix in both the main
check-requirementsjob and the scheduled re-check path before auto-closing.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/triage-pr-requirements.yml |
Adds ` |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
.github/workflows/triage-pr-requirements.yml:191
- Same as above:
|| trueon the entire pipeline masks non-"no matches" errors under-e -o pipefail. Using a filter that exits 0 on empty input (e.g.,awk 'NF'/sed '/^$/d') avoids thegrepexit-code footgun while preserving real failure signaling.
ISSUE_NUMBERS=$(echo -e "$CLOSING_ISSUES\n$REGEX_ISSUES" | sort -u | grep -v '^$' || true)
- Files reviewed: 1/1 changed files
- Comments generated: 1
| CLOSING_ISSUES=$(gh pr view "$NUMBER" --json closingIssuesReferences --jq '.closingIssuesReferences[].number' 2>/dev/null || echo "") | ||
| REGEX_ISSUES=$(echo "$PRBODY" | grep -oE '#[0-9]+|issues/[0-9]+' | grep -oE '[0-9]+' || echo "") | ||
| ISSUE_NUMBERS=$(echo -e "$CLOSING_ISSUES\n$REGEX_ISSUES" | sort -u | grep -v '^$') | ||
| ISSUE_NUMBERS=$(echo -e "$CLOSING_ISSUES\n$REGEX_ISSUES" | sort -u | grep -v '^$' || true) |
There was a problem hiding this comment.
Appending || true to the whole pipeline will also suppress any unexpected failures from sort (or other commands in the pipeline) under -e -o pipefail, which can make real errors harder to detect. Consider replacing the final grep -v '^$' with a filter that returns 0 on empty input (e.g., awk 'NF' / sed '/^$/d') so genuine pipeline failures still surface.
This issue also appears on line 191 of the same file.
| ISSUE_NUMBERS=$(echo -e "$CLOSING_ISSUES\n$REGEX_ISSUES" | sort -u | grep -v '^$' || true) | |
| ISSUE_NUMBERS=$(echo -e "$CLOSING_ISSUES\n$REGEX_ISSUES" | sort -u | awk 'NF') |
When a PR body contains no issue numbers, the
grep -v '^$'pipeline exits with code 1 (no matches). Underbash -e, this kills the script before it reaches theif [ -z "$ISSUE_NUMBERS" ]block that handles the empty-issues case.This causes the check-requirements job to fail with exit code 1 instead of properly labeling the PR as unmet. Example: https://github.com/cli/cli/actions/runs/24323780647
Fix: add
|| trueto both instances (check-requirements job and close-unmet-requirements re-check).