Skip to content

fix(ci): the version guard shallowed the base it needed a merge base with - #1125

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/version-guard-merge-base
Aug 22, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
fix/version-guard-merge-base

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

@sam flagged this in the 13:05 sweep — #1113's version-bump guard died on no merge base, cause identified as the guard's shallow fetch, durable fix noted as unowned. Taking it.

The bug

The job checks out with fetch-depth: 0, then immediately runs:

git fetch --no-tags --depth=1 origin "${{ github.event.pull_request.base.ref }}" >/dev/null 2>&1 || true

That --depth=1 undoes the full fetch. It shallows the base ref, and once the base is one commit deep the fork point is unreachable — so the next line, git diff --name-only "$BASE"...HEAD, dies with fatal: <base>...HEAD: no merge base.

The error names the diff, so it reads as a problem with the PR's contents. It is entirely a problem with the fetch two lines above.

It only fires once the base has advanced past the fork point, which is why the guard worked for weeks and then failed on a PR that had been open a while.

Reproduced before changing anything — and the first attempt failed

My first repro used a 5-commit base and passed: the fork point was still inside the shallow boundary, so merge-base resolved fine and the diff worked. A repro that passes is not a repro, and had I stopped there I'd have "verified" a diagnosis that was right for the wrong reason.

Advancing the base 12 commits past the feature branch and running the guard's own fetch line:

=== before the guard's fetch ===
g
=== after fetch --no-tags --depth=1 origin main ===
fatal: origin/main...HEAD: no merge base

Exact error, exact mechanism.

The fix

  • Drop --depth. checkout already fetched everything; the fetch now only refreshes the ref.
  • Drop || true. A base we cannot fetch makes every comparison below meaningless. Swallowing that failure means comparing against whatever ref happens to be on disk — which is the silent-agreement failure this guard exists to catch, reproduced inside the guard.
  • Add an explicit merge-base check before any diff is trusted, with an error that names the real cause. A guard that cannot see its own baseline must fail loudly rather than pass.

Scope

One workflow file. Does not touch the guard's logic, its package list, or its branches: [main] scoping — only its ability to see the baseline it already intended to use.

🤖 Generated with Claude Code

…with

@sam 56846: #1113's version-bump guard died on "no merge base", and the
durable fix was noted as unowned. Taking it.

The guard checks out with fetch-depth: 0, then immediately runs
`git fetch --no-tags --depth=1 origin <base>`. That --depth=1 UNDOES the
full fetch by shallowing the base ref, and once the base is one commit
deep the fork point is unreachable — so `git diff BASE...HEAD` dies with
"fatal: <base>...HEAD: no merge base". The error names the diff and the
cause is the fetch, which is why it read as a problem with the PR.

It only fires once the base has advanced past the fork point, which is
why the guard worked for weeks and then failed.

Reproduced locally before changing anything, because my first attempt
did NOT reproduce it — with only 5 commits the fork point was still
inside the shallow boundary and everything passed. Advancing the base 12
commits past the feature branch and re-running the guard's own fetch line
gives the exact error. A repro that passes is not a repro.

Two changes:
  - drop --depth, so the fetch cannot shallow what checkout just fetched
  - drop `|| true`. A base we cannot fetch makes every comparison below
    meaningless, so it must stop rather than compare against whatever ref
    is on disk — precisely the silent-agreement failure this guard exists
    to catch.

Plus an explicit merge-base check before any diff is trusted: a guard
that cannot see its own baseline must fail loudly, never pass.

Co-Authored-By: Claude Opus 5 <[email protected]>

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate: approve at 29fb4886. All 11 checks pass — including Source changed ⇒ version bumped itself, which is the strongest self-demonstration available: the fixed guard runs on the PR that fixes it, and passes.

The premise checks out. The comment's argument depends on checkout having already fetched full history, so I verified it rather than reading past it — actions/checkout@v4 with fetch-depth: 0 at :34-36. So --depth=1 on the base genuinely was undoing the full fetch, and the diagnosis holds.

The fix is complete — no siblings. I swept every workflow on main for the same pattern: --depth appears in exactly one place, this file. Nothing else re-shallows a ref it needs a merge base with.

Three things this does beyond the one-line cause, all of which I'd have asked for:

  1. Dropped || true. With set -euo pipefail already in force, that suppression was the only thing keeping a failed fetch from stopping the job — so the guard could silently compare against whatever ref happened to be on disk. A guard that proceeds on an unfetchable baseline is worse than no guard, because it reports green.

  2. A positive control before trusting the diff — git merge-base "$BASE" HEAD with an explicit failure if it can't resolve. That's the discipline that keeps coming up today: prove the instrument can see before believing what it reports. pod-architect built the same shape into the backfill's DERIVATION_LIVE_SQL an hour ago, independently.

  3. The comment explains why it worked for weeks first. "It only fires once the base has advanced past the fork point" is the part that makes this reviewable — a bug that appears long after the code that causes it looks like a change elsewhere, and #1113 got blamed for it. The local repro recipe is in the comment, which is what lets the next person confirm rather than trust.

One thing worth stating for the record. The error this fixes — fatal: <base>...HEAD: no merge base, exit 128 — is exit code 128 from git, not the guard's own exit $fail. That distinction is what let it be triaged correctly on #1134 rather than read as a version violation. After this merges, a red on that check means what it says again.

Not verified: I did not reproduce the shallow-fetch failure locally, and I did not exercise the new merge-base failure branch — it is by construction hard to trigger now that the fetch is correct, which is the point. The evidence that the fix works is this PR's own green guard on a base that has advanced well past its fork point.

@lilyshen0722
lilyshen0722 merged commit 908a0c9 into main Aug 22, 2026
12 checks passed
@lilyshen0722
lilyshen0722 deleted the fix/version-guard-merge-base branch August 22, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant