Repository navigation
fix(scripts): check-shell-lint: here-string, not printf | grep -q under pipefail - #1304
Merged
Merged
Conversation
…er pipefail The covered-set lookup was `printf '%s\n' "$covered" | grep -qxF "$f"` under `set -euo pipefail`. grep -q exits at its first match; when printf still has output left it dies of SIGPIPE, the pipeline returns 141, and a covered file is reported as uncovered (#1290's first CI run, e2e/agent-restart-gap.sh). Use `grep -qxF -- "$f" <<<"$covered"`. //scripts:check_shell_lint_test runs the check against a fake `bazel query` and fake `git ls-files`. The fake covered set is ~1 MiB with the real labels sorting first, so the old shape fails every time, not by luck; an anti-vacuity case rebuilds the old lookup and asserts it does fail there. Closes #1297 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
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.
What
scripts/check-shell-lint.shlooked a file up in the covered set withprintf '%s\n' "$covered" | grep -qxF "$f"underset -euo pipefail.grep -qexits on its first match. Ifprintfstill has output to write, it gets SIGPIPE (or EPIPE,printf: write error: Broken pipe), the pipeline returns non-zero, and a covered file is reported as uncovered. This is what made #1290's first CI run fail one2e/agent-restart-gap.sh.The lookup is now
grep -qxF -- "$f" <<<"$covered", which has no pipe.Test
New target
//scripts:check_shell_lint_test. It is hermetic: fakebazel queryand fakegit ls-files, no repository and no Bazel.printf | grep -qlookup back into a copy, checks that the rewrite actually happened, and asserts the copy reports a covered file as uncovered.origin/mainscript, the test fails. All four covered files come back "uncovered".Checks run:
bazel test //scripts:check_shell_lint_test --runs_per_test=20(20/20 pass),make check-shell-lint(OK, 77 scripts),make format-check,bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //....Same shape elsewhere (reported, not changed here)
Searched
scripts/*.shforproducer | grep -qunder pipefail:scripts/check-registry-config.sh:115runstr -d … <MODULE.bazel | grep -qF …. It is safe today because the files are 18.6 KB and 16.1 KB, under the 64 KiB pipe buffer. Once a MODULE.bazel grows past that, an early match turns into a false "does not override".scripts/check-registry-config.sh:157/164/222/229,scripts/check-registry-lookup.sh:346,scripts/quay-smoke.sh:357and the fake inscripts/check-publish-verify-control.sh:100all pipe one short string, written in a singlewrite(), so they are not at risk.head -1 … | grep -Eqincheck-shell-lint.sh:56andlint-proxy.sh:37:headwrites one line, so this is not at risk.scripts/:.github/workflows/main.yaml:289runsgh … --jq '.comments[].body' | grep -qF "$marker". It is not at risk today. The step sets noshell:, so Actions runs it underbash -e {0}without pipefail, and the status is grep's. If someone later addsshell: bash(which means-eo pipefail) orset -o pipefail, it becomes this same trap.Closes #1297
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr