Conversation
Validate Commits ran the trailer check as a pipeline under pipefail with grep -q. grep -q exits on its first match, so for a commit message larger than the pipe buffer git was still writing, took SIGPIPE, and returned 141. pipefail made that the pipeline result, and the if turned a real match into a miss. The banned trailer passed. Use grep -c with a numeric test. grep -c reads to end of input, so the writer always finishes and no SIGPIPE arises. It keeps grep's own ERE engine and -i semantics, unlike a bash =~ rewrite, so the pattern behaves identically. Verified on four real commits: a 3 MB message carrying a bot trailer reports clean under the old construct and flagged under the new one, while a small bot trailer, a large human trailer, and a large clean message are unchanged. Closes #587
This was referenced Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the fail-open reported in #587.
Validate Commitsmatched the disallowed trailer as a pipeline underset -o pipefail:grep -qexits on its first match. For a commit message larger than the pipebuffer,
gitis still writing at that moment, takesSIGPIPE, and returns141.pipefailpromotes that to the pipeline result, theifsees failure,and a banned trailer that was actually present is reported as absent.
The fix
grep -cwith a numeric test.grep -creads to the end of its input, so thewriter always finishes and no
SIGPIPEarises.grep -cwas chosen over a[[ $message =~ $pattern ]]rewrite deliberately.Both stop the fail-open, but
[[ =~ ]]swaps grep's ERE engine for bash's andneeds
shopt -s nocasematchto keep the-ibehaviour. The pattern contains[[:space:]]and\[bot\], and a silently different match here is worse thanthe bug being fixed.
grep -ckeeps the existing engine and flags unchanged.Verification
Four real commits, each evaluated under both constructs:
grep -q)grep -c)Co-authored-byThe second row is the defect and the only behaviour that changes. A human
co-author is still allowed, and a large clean message still passes, so nothing
starts failing that should not.
actionlintandtrunk checkare clean.Not included
z-shell/zicarries the same construct and needs the same fix; trackedseparately so each repository's change is reviewable on its own.
#592 proposes a test harness for these patterns. It lands after this fix
rather than with it, so the harness can be shown to catch the pre-fix construct
rather than merely passing against the fixed one.
Closes #587