fix(ci): diff pre-commit changed files against the live base branch tip#42152
Open
rusackas wants to merge 1 commit into
Open
fix(ci): diff pre-commit changed files against the live base branch tip#42152rusackas wants to merge 1 commit into
rusackas wants to merge 1 commit into
Conversation
… env payload github.event.pull_request.base.sha is frozen at PR creation, so the changed-files detection on a long-lived PR diffs against the original branch point and picks up all of master's churn since then. This week that list crossed the kernel's per-env-var size limit (MAX_ARG_STRLEN), killing the pre-commit step with "Argument list too long" before bash could start — observed on #41127, where the frozen base predated the antd v6 upgrade and the i18n catalog canonicalization. Diff against HEAD^1 instead: HEAD is the PR merge commit, so its first parent is the current base-branch tip and the diff is exactly the PR's own files. Also fall back to --all-files when the computed list exceeds 100KB, so a PR that legitimately touches thousands of files degrades to a full sweep instead of an unstartable step. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rusackas
requested review from
betodealmeida,
dpgaspar,
eschutho,
geido,
hainenber,
kgabryje,
mistercrunch,
nytai,
sadpandajoe,
sha174n and
villebro
as code owners
July 18, 2026 00:41
Contributor
|
Bito Automatic Review Skipped - Files Excluded |
Contributor
|
IMO, if there are sufficient files getting changed in a long-live PR, like in huge migrations, we should just run the whole precommit against the codebase once a threshold reached. It'd make the logic much more simpler. |
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.
SUMMARY
The pre-commit workflow's changed-files detection diffs against
github.event.pull_request.base.sha, which GitHub freezes at PR creation. On a long-lived PR the diff therefore runs from the original branch point to the merge ref (which contains current master), sweeping in all of master's churn since the branch was cut.This has two failure modes, both observed on #41127 (branched before the antd v6 upgrade and the i18n catalog canonicalization landed):
MAX_ARG_STRLEN, 128KiB), the runner cannot even start bash for the step — it dies withAn error occurred trying to start process '/usr/bin/bash' ... Argument list too longand no hook output. Re-runs replay the same frozen payload, so the job can never go green again; the only workaround is closing and reopening the PR.The fix:
pull_requestevents, diff againstHEAD^1instead. The checkout is the PR merge commit, so its first parent is the current base-branch tip, and the three-dot diff yields exactly the PR's own files regardless of how old the branch is. The existing fail-closed guard (fall back to--all-fileswhen the base can't be resolved) is kept and covers the no-merge-commit edge.--all-filessweep instead of an unstartable step.push/schedulebehavior is unchanged.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (CI behavior)
TESTING INSTRUCTIONS
check-yamlandzizmorpre-commit hooks pass on the workflow file.ADDITIONAL INFORMATION
🤖 Generated with Claude Code