Skip to content

fix: tolerate sigpipe truncating large ai review diffs - #547

Open
margaretjgu wants to merge 1 commit into
mainfrom
fix/ai-review-diff-pipefail
Open

fix: tolerate sigpipe truncating large ai review diffs#547
margaretjgu wants to merge 1 commit into
mainfrom
fix/ai-review-diff-pipefail

Conversation

@margaretjgu

Copy link
Copy Markdown
Member

The diff-fetching step pipes to `head -c 32000` under `pipefail` (explicit in `ai-pr-review.yml`, implicit via GitHub Actions' default bash invocation in `ai-pr-review-external.yml`). Once `head` has its 32000 bytes it closes the pipe, the upstream `gh pr diff`/`gh api compare` gets SIGPIPE on its next write, and `pipefail` turns that into a step failure (exit 141), even though the truncated file is exactly what's wanted. Happens on any PR whose diff exceeds 32000 bytes, e.g. #537.

@github-actions

Copy link
Copy Markdown
Contributor

The fix is correct. When head -c 32000 closes its stdin after reading 32000 bytes, gh gets SIGPIPE and exits non-zero, which was failing the pipeline. Adding || true suppresses that expected non-zero exit.

One thing to verify: the set -e / set -o pipefail behavior in GitHub Actions default shell (bash --noprofile --norc -eo pipefail). With pipefail, the pipeline exit code is the last non-zero from any command in the pipe. The || true applies to the whole pipeline, so it correctly swallows the SIGPIPE-caused failure from gh. This is the right fix.

Nothing else to flag here.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 2 0 0 0.23s
✅ COPYPASTE jscpd yes no no 0.39s
✅ REPOSITORY gitleaks yes no no 40.6s
✅ REPOSITORY git_diff yes no no 0.04s
✅ REPOSITORY secretlint yes no no 1.29s
✅ REPOSITORY trivy yes no no 18.97s
✅ YAML yamllint 2 0 0 0.37s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

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.

1 participant