Skip to content

Fix check-requirements crash when PR has no issue references#15

Merged
BagToad merged 1 commit into
mainfrom
kw/fix-check-requirements-grep
Apr 20, 2026
Merged

Fix check-requirements crash when PR has no issue references#15
BagToad merged 1 commit into
mainfrom
kw/fix-check-requirements-grep

Conversation

@BagToad

@BagToad BagToad commented Apr 14, 2026

Copy link
Copy Markdown
Member

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 [ -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 || true to both instances (check-requirements job and close-unmet-requirements re-check).

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_NUMBERS collection from exiting the step when grep -v '^$' has no matches (empty input).
  • Apply the same fix in both the main check-requirements job 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: || true on 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 the grep exit-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)

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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')

Copilot uses AI. Check for mistakes.
@BagToad BagToad merged commit 17acd37 into main Apr 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants