Repository navigation
fix(ci): detect frontend changes via the paginated files API, fail open (#1782) - #1861
Merged
Merged
Conversation
`gh pr diff --name-only` calls GitHub's diff API, which hard-fails with HTTP 406 `PullRequest.diff too_large` on any PR over 300 files. Under `set -euo pipefail` that killed the `changes` step outright. The visible symptom was a spurious red X on every release PR (routinely 500+ files). The real damage was worse and silent: with the step dead, `needs.changes.outputs.frontend` was empty, the `e2e` job's `if:` fell through to the `ui`-label check, and the suite was SKIPPED on a PR that should have run it. Release PR #1781 (603 files) contains 89 `src/frontend/` files — the correct verdict was `frontend=true`. Swap to the files API, which paginates (3000-file ceiling), and make the step unable to fail: - fail open on a failed PR lookup, a failed file-list call, or a list that cannot be proven complete. This job decides whether e2e runs, so "unable to decide" must mean RUN — never a skip, never a red X. - completeness is proven by comparing the list length against the PR's own `changed_files`. Exact, not a heuristic: it catches truncation at the 3000 ceiling AND a pagination that died mid-way but still exited 0 — the silent-wrong-answer case a `>= 3000` guard cannot see. - captured stderr is echoed into the `::warning::`, so a revoked token or permission regression is visible instead of failing open silently forever. Two deliberate changes a reviewer may read as scope drift: - the `env:` block. The step's command was being rewritten regardless; moving the PR number and repo out of inline `${{ }}` interpolation removes a template-injection class and matches the house style in container-security.yml. - the two `needs.changes.result` clauses on the `e2e` job. Defence in depth, not part of the fix: after this change the step cannot fail from this cause, but a failed or cancelled `changes` job still leaves no verdict, and that must also mean RUN. `cancelled` is covered alongside `failure` so the invariant holds for both. `container-security.yml` detects changed files with `git diff` instead; that job already checks out the repo to build images and this one must not (a full clone of a 96 MB repo turns a ~5s gate into ~40s). The two implementations differ on purpose — noted inline so nobody unifies them. Rejected alternatives: `dorny/paths-filter` (third-party action in CI on a public repo — `tj-actions/changed-files` was supply-chain compromised in March 2025); native `on.pull_request.paths` (workflow-level, would break the `ui`-label manual opt-in #1526 preserved on purpose). Verified — root cause reproduced (`gh pr diff 1781` → HTTP 406, exit 1); 7 stubbed-`gh` cases green against the step text extracted from this YAML, and proven to have teeth (deleting the completeness guard flips the truncation and partial-pagination cases to a wrong `frontend=false`); live: #1781 → `frontend=true`, 603 files, 5s · backend-only #1851 → `frontend=false` · bogus PR → fails open with the 404 in the warning; `actionlint` introduces no new findings (baseline on dev has the same 2). Per CLAUDE.md tiered docs, a bug fix in CI config is commit-message-only: no requirements, architecture, or feature-flow delta — nothing in them governs GitHub Actions config. Fixes #1782 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The `|| needs.changes.result == 'cancelled'` guard on the e2e job defeated
`cancel-in-progress`: GitHub cancels a run by re-evaluating every job's `if`
and keeping the job when it returns true, which is what `always()` means. With
`cancel-in-progress: true` for PRs, the dominant producer of a `cancelled`
result is a superseded push — so the clause turned every superseded push into a
full 25-minute Docker-stack + Playwright run, whose failure posts the very red X
this issue exists to remove. A cancelled run has been superseded; the
replacement run evaluates from scratch. `failure` is kept — that is a real
"no verdict" case.
Also corrects the job header comment, which still described the mechanism this
fix removed ("Dependency-free (gh diff)"). Detection is now the PR files API;
the property worth naming is that it needs no checkout.
Records the pitfall in docs/memory/learnings.md and marks #1782 fixed in the
0.8.5 known-issues note.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Resolve by running |
vybe
approved these changes
Jul 29, 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.
Problem
The
frontend-e2echangesjob detected frontend edits withgh pr diff --name-only. Thatcalls the diff API, which hard-fails with HTTP 406 above 300 files. Every release-sized
PR therefore did two bad things at once:
frontendunset, so the e2e suite was skipped — not run — on exactly thelargest, riskiest PRs.
GitHub's own 406 body names the fix: "Consider using 'List pull requests files' API."
Change
gh api repos/{repo}/pulls/{n}/files --paginate(the files API,which paginates) instead of the diff API.
frontend=trueandexit 0. This job decides whether e2e runs, so "unable to decide" mustmean run, and must never mean a red X.
changed_files. An exact comparison catches both truncation at GitHub's 3000-file ceilingand a pagination that died mid-way but still exited 0 — the latter is silently missed by a
>= 3000heuristic.${{ }}interpolation intoenv:(PR_NUMBER,REPO) rather than splicingexpressions into the shell.
|| needs.changes.result == 'failure'on the e2e job as defence in depth.One deliberate non-change
An earlier revision also carried
|| needs.changes.result == 'cancelled'. That was removed,and the reasoning is recorded in
docs/memory/learnings.md. GitHub cancels a run byre-evaluating each job's
ifand keeping the job whenever it returns true — that is preciselywhat
always()means. This workflow setscancel-in-progress: truefor PRs, so the dominantproducer of a
cancelledresult is a superseded push. The clause would have turned everysuperseded push into a full 25-minute Docker-stack + Playwright run whose failure posts the very
red X this issue exists to remove. A cancelled run has been superseded; the replacement run
evaluates from scratch.
failureis kept — that one is a genuine "ran and lost" case.container-security.ymldetects changed files withgit diffinstead. It already checks out therepo to build images; this job must not (a clone turns a ~5s gate into ~40s). The two
implementations differ on purpose — there's a comment saying so.
Verification
/verify-localcannot exercise a GitHub Actions workflow, so verification was done by extractingthe step's shipped bytes straight out of the YAML and executing them against the real GitHub
API, asserting on the two things the workflow actually consumes: the step's exit code and the
contents of
$GITHUB_OUTPUT. The pre-fix step was extracted fromorigin/devand run throughthe identical harness for a symmetric before/after.
13/13 cases pass.
GITHUB_OUTPUTgh pr diffon PR #1781 (603 files)1❌0frontend=true0frontend=trueGH_TOKEN(401)0frontend=true0frontend=true0frontend=false0frontend=true0frontend=true0frontend=false0frontend=true0frontend=true0frontend=true0frontend=falseCase 1 is the reported bug reproduced exactly: red X and no verdict. Cases 10–13 use a
ghshim on
PATH, since no real PR can be made to truncate on demand; case 13 is the control thatstops the guard from passing vacuously. Cases 3–5 confirm the fail-open branch is reached by
genuinely different failures (bad PR, bad credentials, bad repo), not one code path three times.
actionlintreports the same 2 pre-existing shellcheck findings before and after, both inother jobs — this change adds none.
Live run on this PR
The harness above runs locally, so it cannot exercise the Actions runner itself — job-level
ifevaluation,
needswiring,$GITHUB_OUTPUTplumbing between jobs, or theGITHUB_TOKENpermission set. That needs a real run. This PR produced one
(run 30384069438):
changes— success in 5s, 0 annotations (so the fail-open warning was not emitted).changed files: 3— the new code path ran (that line exists only in the fix) and thecompleteness check agreed with the PR's
changed_files.e2e— skipped, correct: this PR touches nosrc/frontend/**.That proves, on the runner: the job is green (the red X is gone), the files-API path works with
the workflow's own
GITHUB_TOKENandpull-requests: readscope, and the verdict propagatesthrough
needsto gatee2e.What is still not proven on the runner
This PR is 3 files, so its live run exercises neither the >300-file path nor the
fail-open branch — both are covered only by the local harness against the real API (cases
1–5, 10–13). The next release-sized PR is the first live exercise of the >300-file path.
The
cancelled-clause removal is not covered by any automated case here. It is derived fromdocumented Actions cancellation semantics and validated by reading
concurrency.cancel-in-progressin this same file; the reasoning is written up indocs/memory/learnings.mdso a future reader doesn't "helpfully" re-add it.Closes #1782