Skip to content

fix(ci): diff pre-commit changed files against the live base branch tip#42152

Open
rusackas wants to merge 1 commit into
masterfrom
fix-precommit-stale-base-sha
Open

fix(ci): diff pre-commit changed files against the live base branch tip#42152
rusackas wants to merge 1 commit into
masterfrom
fix-precommit-stale-base-sha

Conversation

@rusackas

Copy link
Copy Markdown
Member

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):

  1. Silent over-linting: pre-commit runs on hundreds/thousands of files the PR never touched.
  2. Hard failure: once the file list crosses the kernel's per-env-var limit (MAX_ARG_STRLEN, 128KiB), the runner cannot even start bash for the step — it dies with An error occurred trying to start process '/usr/bin/bash' ... Argument list too long and 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:

  • For pull_request events, diff against HEAD^1 instead. 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-files when the base can't be resolved) is kept and covers the no-merge-commit edge.
  • Cap the computed list at 100KB (safely under the 128KiB limit): a PR that legitimately touches thousands of files now degrades to an --all-files sweep instead of an unstartable step.

push/schedule behavior is unchanged.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A (CI behavior)

TESTING INSTRUCTIONS

  • check-yaml and zizmor pre-commit hooks pass on the workflow file.
  • Behavior is observable on any PR whose branch point predates a large master change: previously the changed-files list contained all of master's intervening churn; with this change it contains only the PR's files. The failing case is reproducible on fix(sqllab): apply SQL_QUERY_MUTATOR in SQL Lab when MUTATE_AFTER_SPLIT is set #41127 prior to its close/reopen.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

… 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>
@dosubot dosubot Bot added the github_actions Pull requests that update GitHub Actions code label Jul 18, 2026
@bito-code-review

bito-code-review Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Files Excluded

Bito didn't auto-review this change because all changed files are in the exclusion list for automatic reviews. No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the excluded files settings here, or contact your Bito workspace admin at evan@preset.io.

@hainenber

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants