Skip to content

ci: sync-lemonade-fork dies on an emptied cherry-pick (main red 15:07Z), and a lane token cannot push the fix #2440

Closed

Description

@bong-water-water-bong

main's sync-lemonade-fork is red, the cause is one unguarded cherry-pick --continue, and a fix cannot be pushed from a lane token

Run 43608459423 (sync-lemonade-fork, on main's tip 3ac4a5e1, 15:07:32Z) fails in "Port upstream's latest release into the fork" with git's own words:

The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:
    git commit --allow-empty
Otherwise, please use 'git cherry-pick --skip'
##[error]Process completed with exit code 1.

What the step does today, and the one case it misses

for c in $picks; do
  if git cherry-pick -x "$c" > /dev/null 2>&1; then continue; fi
  mapfile -t changed < <(git diff --name-only --diff-filter=U)
  if [ "${#changed[@]}" -eq 0 ]; then            # failed with no conflict: already applied
    GIT_EDITOR=true git cherry-pick --skip ... ; continue
  fi
  conflicts+=("${changed[@]}")
  git checkout --ours -- "${changed[@]}" ...      # keep the fork's side
  git add -A -- "${changed[@]}"
  GIT_EDITOR=true git cherry-pick --continue > /dev/null   # <-- unguarded
done

The covered case is a pick that fails with no unmerged files. The uncovered case is a pick that conflicts, is resolved with --ours, and is then empty — because the release's whole change to that file is exactly what "keep the fork's side" discards. --continue refuses that state, and under set -e the run dies there.

Reproduced offline (git init in a scratch dir):

base -> fork rewrites the line -> release rewrites it differently
cherry-pick -x <release>                 rc=1   (conflict, as intended)
git checkout --ours -- f.txt; git add -A staged diff: 0 files   <-- the pick is now EMPTY
git cherry-pick --continue               rc=1   <-- set -e kills the job here
git cherry-pick --skip                   rc=0   tree clean, HEAD still the fork's commit

The fix (4 lines, in the branch below)

             conflicts+=("${changed[@]}")
             git checkout --ours -- "${changed[@]}" 2>/dev/null || true
             git add -A -- "${changed[@]}"
-            GIT_EDITOR=true git cherry-pick --continue > /dev/null
+            # Keeping the fork's side of a file the release also rewrote can leave the pick with
+            # NOTHING to commit -- the release's whole change to those files is what we just
+            # discarded -- and `git cherry-pick --continue` refuses an empty pick ("The previous
+            # cherry-pick is now empty ... use 'git cherry-pick --skip'"). Unguarded, that exit 1
+            # failed the whole sync on 2026-11-14 15:07Z. It is the same outcome as the skip in the
+            # no-conflict branch above: the fork's side is kept, and the files stay in the list for
+            # a person because the release's version of them is not in the port.
+            if ! GIT_EDITOR=true git cherry-pick --continue > /dev/null 2>&1; then
+              GIT_EDITOR=true git cherry-pick --skip > /dev/null 2>&1 || git cherry-pick --abort
+            fi

The files stay in conflicts either way, so the human list is unchanged — the release's version of those files is not in the port, and a person still has to apply it.

Why this issue and not a PR

Branch os3-sync-empty-pick (cd928180) has the fix plus two arms in tests/workflow_shell_test.py, and both are proven: the suite passes with the fix and fails with it reverted (rc 1) — the artifact arm reads the step and requires the guard, the behaviour arm rebuilds the CI case in a scratch repo and asserts the conflict, the emptied pick, that --continue refuses it, and that --skip recovers while keeping the fork's commit.

It cannot be pushed from a lane token:

! [remote rejected] os3-sync-empty-pick -> os3-sync-empty-pick
  (refusing to allow an OAuth App to create or update workflow
   `.github/workflows/sync-lemonade-fork.yml` without `workflow` scope)

So this needs either the workflow-scoped token (HRX_BUMP_TOKEN already has Contents/PRs/Actions on this repo; the sync itself deliberately never touches a workflow file, which is why its docs say the scope is not needed) or the owner. The patch is also attached as a .patch in the first comment so it needs no branch.

Activity

  1. bong-water-water-bong commented on Nov 14, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    From cd92818 Mon Sep 17 00:00:00 2001
    From: t [email protected]
    Date: Sat, 14 Nov 2026 11:18:28 -0400
    Subject: [PATCH] sync: an emptied cherry-pick is a skip, not a failed port
    (main's sync, 15:07Z)

    sync-lemonade-fork.yml's port loop already skips a pick that fails with no
    unmerged files. The case it did not cover is a pick that conflicts, is resolved
    with checkout --ours -- and then has NOTHING left to commit, because the
    release's whole change to those files is what the resolution discarded. git cherry-pick --continue refuses that state ("The previous cherry-pick is now
    empty ... use 'git cherry-pick --skip'"), and under set -e the whole sync died.

    Measured on the run for 3ac4a5e (43608459423, step "Port upstream's latest
    release into the fork"):

    The previous cherry-pick is now empty, possibly due to conflict resolution.
    Otherwise, please use 'git cherry-pick --skip'
    ##[error]Process completed with exit code 1.
    

    Reproduced offline: base -> fork rewrites one line -> release rewrites it
    differently -> conflict (rc 1) -> checkout --ours leaves a staged diff of 0
    files -> --continue rc 1. With the guard, --skip returns 0, the tree is clean
    and HEAD is still the fork's commit, which is the same outcome as the existing
    no-conflict skip: the fork's side is kept, and the file stays in the conflict
    list for a person because the release's version of it is not in the port.

    Tests: two arms in tests/workflow_shell_test.py, which already drives workflow
    steps offline. One reads the step and requires the --continue to be guarded
    (reverting the fix turns the suite red, verified); the other rebuilds the CI case
    in a scratch repo and asserts the conflict, the emptied pick, that --continue
    refuses it and that --skip recovers while keeping the fork's side.

    The port step clones both remotes through gh repo clone, which the file's stub
    does not model, so the arms exercise the pick loop rather than the whole step --
    stated here rather than left to be discovered.

    .github/workflows/sync-lemonade-fork.yml | 11 +++++++-
    tests/workflow_shell_test.py | 36 ++++++++++++++++++++++++
    2 files changed, 46 insertions(+), 1 deletion(-)

    diff --git a/.github/workflows/sync-lemonade-fork.yml b/.github/workflows/sync-lemonade-fork.yml
    index be1f79ce0..c2644416a 100644
    --- a/.github/workflows/sync-lemonade-fork.yml
    +++ b/.github/workflows/sync-lemonade-fork.yml
    @@ -198,7 +198,16 @@ jobs:
    conflicts+=("${changed[@]}")
    git checkout --ours -- "${changed[@]}" 2>/dev/null || true
    git add -A -- "${changed[@]}"

    •        GIT_EDITOR=true git cherry-pick --continue > /dev/null
      
    •        # Keeping the fork's side of a file the release also rewrote can leave the pick with
      
    •        # NOTHING to commit -- the release's whole change to those files is what we just
      
    •        # discarded -- and `git cherry-pick --continue` refuses an empty pick ("The previous
      
    •        # cherry-pick is now empty ... use 'git cherry-pick --skip'"). Unguarded, that exit 1
      
    •        # failed the whole sync on 2026-11-14 15:07Z. It is the same outcome as the skip in the
      
    •        # no-conflict branch above: the fork's side is kept, and the files stay in the list for
      
    •        # a person because the release's version of them is not in the port.
      
    •        if ! GIT_EDITOR=true git cherry-pick --continue > /dev/null 2>&1; then
      
    •          GIT_EDITOR=true git cherry-pick --skip > /dev/null 2>&1 || git cherry-pick --abort
      
    •        fi
           done
           # One commit for the port, as the old merge produced: main's history stays one line per
           # upstream release. keep_fork_github for the same reason as before - the push must not
      

    diff --git a/tests/workflow_shell_test.py b/tests/workflow_shell_test.py
    index 0b1241a95..92ff61533 100644
    --- a/tests/workflow_shell_test.py
    +++ b/tests/workflow_shell_test.py
    @@ -29,6 +29,7 @@ Two guarantees, both offline (CI installs no PyYAML, so the blocks are lifted ou
    """
    import json
    import os
    +import pathlib
    import re
    import subprocess
    import sys
    @@ -204,6 +205,41 @@ if script:
    p.returncode != 0 and "could not be bumped" in p.stdout + p.stderr, f"rc={p.returncode}")
    check("pin-watch: and opens nothing", not [c for c in calls if c.startswith("pr create")], str(calls))

    +# 3. sync-lemonade-fork: keeping the fork's side of a conflicting commit can EMPTY the pick, and an
    +# unguarded cherry-pick --continue then fails the whole port - which is how main's sync went red
    +# on 2026-11-14 15:07Z ("The previous cherry-pick is now empty ... use 'git cherry-pick --skip'").
    +# Two arms: the step must keep the guard, and the guard must be the thing that works.
    +text = open(os.path.join(WORKFLOWS, "sync-lemonade-fork.yml")).read()
    +script = step_script(text, "Port upstream's latest release into the fork")
    +check("sync: has the port step", script is not None)
    +if script:

    • check("sync: an emptied pick is skipped, not left to set -e",
    •      "if ! GIT_EDITOR=true git cherry-pick --continue" in script)
      
    • with tempfile.TemporaryDirectory() as tmp:
    •    def g(*a):
      
    •        return subprocess.run(["git"] + list(a), cwd=tmp, capture_output=True, text=True)
      
    •    g("init", "-q"); g("config", "user.email", "t@e"); g("config", "user.name", "t")
      
    •    pathlib.Path(tmp, "f.txt").write_text("base\n")
      
    •    g("add", "-A"); g("commit", "-qm", "base"); base = g("rev-parse", "HEAD").stdout.strip()
      
    •    g("checkout", "-q", "-b", "port"); pathlib.Path(tmp, "f.txt").write_text("fork\n")
      
    •    g("commit", "-qam", "fork"); fork_head = g("rev-parse", "HEAD").stdout.strip()
      
    •    g("checkout", "-q", "-b", "up", base); pathlib.Path(tmp, "f.txt").write_text("release\n")
      
    •    g("commit", "-qam", "release"); rel = g("rev-parse", "HEAD").stdout.strip()
      
    •    g("checkout", "-q", "port")
      
    •    pick = g("cherry-pick", "-x", rel)
      
    •    check("sync: the release commit does conflict with the fork's line", pick.returncode != 0, pick.stderr[:120])
      
    •    g("checkout", "--ours", "--", "f.txt"); g("add", "-A", "--", "f.txt")
      
    •    empty = subprocess.run(["git", "diff", "--cached", "--quiet"], cwd=tmp).returncode == 0
      
    •    check("sync: and keeping ours leaves the pick empty (the CI failure)", empty)
      
    •    cont = subprocess.run(["git", "cherry-pick", "--continue"], cwd=tmp, capture_output=True, text=True,
      
    •                          env=dict(os.environ, GIT_EDITOR="true"))
      
    •    check("sync: `--continue` alone refuses that empty pick", cont.returncode != 0, f"rc={cont.returncode}")
      
    •    skip = subprocess.run(["git", "cherry-pick", "--skip"], cwd=tmp, capture_output=True, text=True,
      
    •                          env=dict(os.environ, GIT_EDITOR="true"))
      
    •    check("sync: `--skip` recovers it and keeps the fork's side",
      
    •          skip.returncode == 0 and g("rev-parse", "HEAD").stdout.strip() == fork_head, f"rc={skip.returncode}")
      

    if failures:
    print(f"\n{len(failures)} check(s) failed")
    sys.exit(1)

    2.53.0

  2. bong-water-water-bong commented on Nov 14, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    State as of 15:25Z: fix verified, still unlandable from a lane identity, and exactly what unblocks it

    Re-checked both blockers rather than assuming they still hold.

    The push is still refused. Same token, same file:

    $ git push -u origin os3-sync-empty-pick
     ! [remote rejected] os3-sync-empty-pick -> os3-sync-empty-pick
       (refusing to allow an OAuth App to create or update workflow ...)
    $ gh auth status
      Token scopes: 'gist', 'read:org', 'repo'
    

    No workflow scope, and only one account is configured, so there is no second identity to try.

    The fix is still correct and still based on main. In ~/1bit-engine (branch os3-sync-empty-pick, cd9281802, and git merge-base --is-ancestor origin/main HEAD passes — no rebase needed against 3ac4a5e19):

    ok   sync: an emptied pick is skipped, not left to `set -e`
    ok   sync: and keeping ours leaves the pick empty (the CI failure)
    ok   sync: `--continue` alone refuses that empty pick
    ok   sync: `--skip` recovers it and keeps the fork's side
    
    all checks passed
    

    Four arms, not two: the pair that reproduces the CI failure and the pair that shows recovery. The whole tests/workflow_shell_test.py suite is green.

    What unblocks it — one of these, and I cannot do either:

    1. A token with workflow scope (a fine-grained PAT with Workflows: write, or a classic PAT with workflow) applied to this branch push. The branch and its commit already exist locally and need nothing but git push.
    2. A maintainer pushing os3-sync-empty-pick — the branch is 1 commit on top of 3ac4a5e19 and the working tree is clean.

    Until then main stays red on that job, and the failure is a noise failure: the sync aborts after the conflict resolution has already happened, so the port is half-applied and the next run starts from a dirty state. That is worth more than a red badge — it is the reason to unblock this before any other lane PR needs the job green.

    Why I am not doing it differently: the loop lives inline in .github/workflows/sync-lemonade-fork.yml (lines 178–201), so there is no non-workflow file I could fix instead. Moving the loop into scripts/ would need the same YAML edit to call it. The only paths are the two above.

  3. bong-water-water-bong commented on Nov 14, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Confirmed from a second lane token, and the patch still applies and passes on today's main — so the only thing missing is the scope.

    I tried to land it rather than comment on it, since the issue's blocker is a token question and the issue did not say whose:

    $ git push origin HEAD:refs/heads/pkg/2440-sync-guard
     ! [remote rejected] HEAD -> pkg/2440-sync-guard
       (refusing to allow an OAuth App to create or update workflow `.github/workflows/sync-lemonade-fork.yml` without `workflow` scope)
    

    Verbatim the same rejection as os3-sync-empty-pick, from a different lane's token. So this is not one lane's token: every lane token is
    an installation of the same OAuth App, and none of them carries workflow scope. That narrows the fix to two doors and closes the third
    possibility ("maybe another lane can push it").

    What I verified before that, on a fresh branch off today's origin/main (3ac4a5e1-era, not the author's base):

    step result
    git apply the .patch from the first comment clean, 2 files, +46/−1
    python3 tools/copyright.py --check ok
    python3 tests/workflow_shell_test.py all checks passed — including "--continue alone refuses that empty pick" and "--skip recovers it and keeps the fork's side"

    So the artifact is sound and current; it is blocked on exactly one thing, and neither of the two doors is open to a lane:

    1. a token with workflow scope — the owner's, or HRX_BUMP_TOKEN if it has it (the issue notes the sync deliberately never touches
      a workflow file, which is why its own docs say the scope is unnecessary — that assumption is what this run disproved);
    2. the owner applying the attached patch, which needs no branch and no scope.

    I did not open a PR: a PR whose branch cannot be pushed is a dead link, and the patch is already the better artifact. My local branch is
    deleted rather than left around.

    One thing worth deciding alongside the fix: if the sync must never touch a workflow file, then this change to its own workflow is the
    first one that does — worth a line in the workflow's header saying the workflow scope is needed for changes to this file, so the next
    lane does not spend the four hours the filer spent believing the device was broken.

  4. bong-water-water-bong commented on Nov 14, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The fix is in engine#2454 (someone with the workflow scope carried the patch from this issue verbatim). I ran their head: tests/workflow_shell_test.py rc=0 on all six sync arms, and reverting just the guard turns it red on the artifact arm — so the fix is load-bearing, not decorative. This issue can close when that PR merges; the scope blocker it records is still the useful part of it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions