Skip to content

A main push can abort in Fetch origin/main (! [rejected] … non-fast-forward) before lint and the suite run #807

Closed
Birfy/FlyBot
#25

Description

@Birfy

What happens

On Birfy/FlyBot, a push to main killed the ubuntu-latest · Node 24 · DSH 0.2.0-rc.2 job inside the step Fetch origin/main for arch-docs check, before npm run lint and the suite ever ran, so tests-ok failed with no test result at all.

Run 39898972351 (push of 21ee37d3), job 120235871280, log verbatim:

 ! [rejected]        main       -> origin/main  (non-fast-forward)
##[error]Process completed with exit code 1.

The step, at 61a6af6f

.github/actions/flybot-tests/action.yml:41-57:

set -euo pipefail
git fetch --no-tags --depth=1 origin main:refs/remotes/origin/main
for n in 50 200 1000 5000; do
  if git merge-base origin/main HEAD >/dev/null 2>&1; then break; fi
  git fetch --no-tags --deepen="$n" origin main 2>/dev/null || true
  git fetch --no-tags --deepen="$n" origin HEAD 2>/dev/null || true
done
if ! git merge-base origin/main HEAD >/dev/null 2>&1; then
  git fetch --unshallow 2>/dev/null || git fetch --no-tags origin main
fi
git merge-base origin/main HEAD >/dev/null
git rev-parse --verify origin/main^{commit}

Why, precisely

git fetch <refspec> without --force updates refs/remotes/origin/main only as a fast-forward. actions/checkout has already fetched the branch tip as of its own fetch into that same ref, so when main advanced between the checkout and this step — or, equivalently, when the run's HEAD is behind the branch tip that checkout recorded — the local refs/remotes/origin/main is newer than the commit being fetched, and git refuses to move it backwards. set -euo pipefail then aborts the whole composite action.

This is ordering, not code. Two pushes 8 seconds apart: 21ee37d3 at 04:11:18 and 61a6af6f at 04:11:26. The run for 61a6af6f passed the same step in 201 ms and printed its own sha (61a6af6f…); the run for 21ee37d3 was rejected. A fresh checkout during the second push had origin/main at the newer tip.

Expected

The step must obtain the base commit without updating a ref that may already be ahead:

  • Fetch by name into FETCH_HEAD and read it from there: git fetch --no-tags --depth=1 origin refs/heads/main then git rev-parse FETCH_HEAD, or
  • Keep the named ref but make the update explicit: +main:refs/remotes/origin/main.

Either way set -euo pipefail stays, and the existing git merge-base verification stays — a race must not abort before lint and the suite, and must not silently let arch-docs diff against the wrong base. Do not wrap the fetch in || true: that would let the check run against a stale or missing base, which is worse than red.

Does this block the fork's PR gates?

No — do not gate PRs on it; fix it before trusting fork CI as evidence. Reasoning:

  • The failure needs the base ref to be ahead of what is being fetched, so it is a race, not a deterministic PR failure. pull_request runs fetch the merge ref and normally re-fetch main at the same tip, which is a no-op.
  • It can still hit a PR run (main moves in the seconds between checkout and the step), so a red at this step must be read as "no tests ran", not "the code broke" — rerun the run.
  • It must be fixed before any decision uses "fork CI green" as merge evidence, because until then a red here and a red in the suite look the same in the PR check list.

Done when

  • The step fetches the base with an explicit force or through FETCH_HEAD, and git rev-parse --verify of the base still succeeds.
  • A check covers the shape that failed: in one job, fetch the current tip into the ref and then fetch an older commit the same way; neither may abort, and the base resolved afterwards is the older commit.
  • A run on a branch that is behind the tip reaches Lint (green or red on its own merits) instead of dying in the fetch step.
  • actionlint passes (npm run lint lints workflows in the package job).

Kill conditions

  • Restore the unforced main:refs/remotes/origin/main → the two-fetch check fails.
  • Add || true around the fetch → the "base is still verified and correct" check fails.
  • Drop the merge-base/rev-parse verification → the wrong-base check fails.

Activity

  1. added
    bug
    agent-ready
    area:automation
    on Oct 23, 2026
  2. Birfy commented on Oct 23, 2026

    @Birfy
    CollaboratorAuthor

    Written-by: Dev4

    Claiming this one. Branch fix/807-fetch-base-refspec on Birfy/FlyBot, PR Birfy#25 (base main at 61a6af6f, tip 265ec4476fd17fca59c1163719f08902928fe780).

    What it does, matching the two options in "Expected": the base fetch becomes git fetch --no-tags --depth=1 origin +main:refs/remotes/origin/main — the named ref is kept, the update is explicit — with the reason in a comment above it. set -euo pipefail stays, the fetch is not wrapped in || true, and git merge-base origin/main HEAD plus git rev-parse --verify origin/main^{commit} still verify the base, so a missing or wrong base fails the job instead of running arch-docs against it.

    The check the issue asks for is .github/scripts/fetch-base.test.mjs: it reads the real run: block out of the action and executes it in a scratch repository (depth-1 clone, then main moves back), so neither the refspec nor the verification lines can drift without a red. Local: 3/3 new, .github/scripts 245/245, testing-layers --check clean, changelog check clean. All three kill conditions were run and each turns the intended test red — details in the PR body under "Red without the source change".

    Other git fetch call sites were checked: the --deepen/--unshallow lines only write FETCH_HEAD, and live-e2e.yml/nightly.yml do a full checkout and fetch nothing themselves.

  3. added
    agent-working
    on Oct 23, 2026
  4. self-assigned this
    on Oct 23, 2026
  5. removed
    agent-ready
    on Oct 23, 2026
  6. Birfy commented on Oct 23, 2026

    @Birfy
    CollaboratorAuthor

    Landed in the fork as cede8422 (#25, squash). Closed by the cross-repository Fixes line when that pull request merged; the state labels agent-working/agent-pr were cleared here because a closed issue carries history, not workflow state.

  7. removed
    agent-working
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:automationbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions