fix(sdlc): harden authority-case-check.yml against grep|head SIGPIPE on long PR bodies#3836
Conversation
…on long PR bodies The "Parse AuthorityCase reference from PR body" step extracted ids with `grep -oiE 'PATTERN' | head -1` under `set -euo pipefail`. When grep's -o output exceeds its ~4KiB stdio buffer it flushes in pieces; head -1 closes the pipe after the first line, so grep's next write takes SIGPIPE -> exit 141 -> pipefail + set -e -> the step exits 1. This deterministically red-blocked any methodology PR whose body carried enough CASE-/cc-task matches (reproduced through the actual run block: exit 141). Replace the three extraction pipes with grep -m1 -oiE ... here-string + || true plus a first-match parameter-expansion trim: - grep -m1 stops after the first matching line, so grep never keeps writing into a pipe a downstream stage closed early -- no SIGPIPE. - || true keeps a no-match (grep exit 1) from tripping set -e, retiring the now-redundant `if echo | grep -q` guards (themselves a latent echo-pipe SIGPIPE for >64KiB bodies). - the trim keeps only the first match when -o emits several on one line, preserving the original head -1 semantics and keeping a multi-line value out of GITHUB_OUTPUT. - the pre-methodology guard now reads from a here-string (no echo pipe). set -euo pipefail is retained. Regression test tests/test_authority_case_check_sigpipe.py lifts the real run block from the workflow YAML and executes it: a >2KiB single-ref body parses to exit 0, a many-match body that exits 141 pre-fix now exits 0, and same-line multi-match yields a single newline-free id. Task: reform-fix-authority-case-check-sigpipe-20260601 AuthorityCase: CASE-SDLC-REFORM-001 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe workflow step parsing AuthorityCase metadata from PR bodies is rewritten to avoid SIGPIPE failures using here-strings and parameter expansion instead of piped grep/head operations. A regression test module is added that executes the actual parse step against crafted PR bodies to validate extraction across edge cases. ChangesAuthorityCase metadata parsing robustness
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
… SC2001) Feeding sed a here-string (single variable) trips shellcheck SC2001, which the CI actionlint gate fails on. Reading from the grep stream (as the original did) is shellcheck-clean and equally SIGPIPE-safe: grep -m1 bounds the output and sed reads it to EOF, so nothing closes the pipe early. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AuthorityCase: CASE-SDLC-REFORM-001
cc-task:
reform-fix-authority-case-check-sigpipe-20260601What
The
authority-case-check.yml"Parse AuthorityCase reference from PR body" step extracted ids withgrep -oiE 'PATTERN' | head -1underset -euo pipefail. When grep's-ooutput exceeds its ~4 KiB stdio buffer it flushes in pieces;head -1closes the pipe after the first line, so grep's next write takes SIGPIPE -> exit 141 -> pipefail + set -e -> the step exits 1. This deterministically red-blocked any methodology PR whose body carried enough CASE-/cc-task matches (this is what blocked hapax-dev #3834).Fix
The three extraction pipes now use
grep -m1 -oiE ... <<<"$PR_BODY" || trueplus a first-match parameter-expansion trim:grep -m1stops after the first matching line, so grep never keeps writing into a pipe a downstream stage closed early -- no SIGPIPE.|| truekeeps a no-match from trippingset -e, retiring the redundantecho | grep -qguards (themselves a latent echo-pipe SIGPIPE on >64 KiB bodies).-oemits several on one line, preserving the oldhead -1semantics and keeping a multi-line value out of$GITHUB_OUTPUT.set -euo pipefailis retained.Test
tests/test_authority_case_check_sigpipe.pylifts the real run block from the workflow YAML and executes it against crafted bodies. The many-match body exits 141 pre-fix and 0 post-fix; the >2 KiB single-ref body parses cleanly; same-line multi-match yields a single newline-free id.uv run pytest tests/test_authority_case_check_sigpipe.py-> 6 passed.This PR's own AuthorityCase Check runs the patched workflow from the PR head, proving the fix end-to-end.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests