fix(ci): fetch the base ref with full history so the scope check has a merge base - #2554
Closed
kyle-sexton wants to merge 1 commit into
Closed
fix(ci): fetch the base ref with full history so the scope check has a merge base#2554kyle-sexton wants to merge 1 commit into
kyle-sexton wants to merge 1 commit into
Conversation
…a merge base The guard fetched the base ref with --depth=1, then asked for a three-dot diff against it. A three-dot diff needs a merge base, and a shallow fetch truncates the base ref to a lone commit, so any branch not sitting on the base's current tip died with "fatal: origin/main...HEAD: no merge base" before the scope check could run. Reproduced deterministically on #2539 across two runs with the branch seven commits behind main. The workflow already checks out with fetch-depth: 0, so dropping --depth=1 costs nothing — it is a normal fetch against an already-complete clone. The guard's fail-closed posture is untouched; it just gets a usable merge base and evaluates scope as designed instead of erroring. Covered two ways: a static guard against reintroducing the shallow fetch, and a behavioural test that builds a behind-main fixture and asserts both directions — full fetch yields a working three-dot diff, shallow fetch breaks it. The second assertion means the test reports if the regression it pins ever stops being real rather than passing vacuously. The fixture chains with && instead of set -e: enabling errexit anywhere in that file switches on SC2310 for every pre-existing function-in-a-condition above it. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Contributor
Author
|
Closing as superseded: #2548 (merged to main as |
Contributor
Author
|
Superseded by #2548 — the shallow-fetch scope check this PR patched was removed from the guard entirely. |
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
scripts/verify-security-review-evidence.shfetched the base ref shallow and then asked for athree-dot diff against it:
A three-dot diff needs a merge base.
--depth=1truncates the base ref to a lone commit, so anybranch not sitting on the base's current tip dies with
fatal: origin/main...HEAD: no merge basebefore the scope check can run. At this repo's merge rate that is most PRs more than a few minutes
old.
Observed on #2539: deterministic across two independent runs (
31655807987, jobs94310219602and94312908610), branch seven commits behind main.The failure is fail-closed — correct, and clearly deliberate in the script's comments — but the guard
never reaches the evidence check it exists to perform, and goes red on PRs it has nothing to say
about.
Fix: drop
--depth=1..github/workflows/claude-security-review.ymlalready checks out withfetch-depth: 0, so this is a normal fetch against an already-complete clone, not a cost regression.Nothing about the fail-closed posture changes.
Not done here: defending against being called from a genuinely shallow clone
(
--is-shallow-repository→--unshallow). The only caller checks out full history, so that wouldbe scaffolding for a case that does not exist. Raised as a question in #2553 rather than built.
Test plan
scripts/verify-security-review-evidence.sh.test.sh— all checks pass, including two new ones:--depthfetch of the base ref is reintroduced;full fetch yields a working three-dot diff, and the shallow fetch breaks it. The second
assertion fails loudly if the regression ever stops being real, so the test cannot start passing
vacuously and leave the static guard unexamined.
scripts/affected-tests.sh --run— 1 suite selected, passes.shellcheckwith the repo's.shellcheckrc: exit 0, matching the pre-change baseline(verified by stashing and re-running). The fixture chains with
&&rather thanset -ebecauseenabling errexit anywhere in that file switches on SC2310 for every pre-existing
function-in-a-condition above it; the one new
SC2016carries the same disable directive andrationale the file already uses two blocks earlier.
editorconfig-checkerclean; no file-mode changes.Related
Closes #2553
Found while shipping #2539, where this gate went red on a docs-only change with no finding of its
own.