Skip to content

ci: re-running a completed backport posts a false "Backport failed" comment on the original PR #3588

Description

Adding a second backport label to a PR whose first backport already merged makes the bot claim the backport failed. The comment is wrong, it names a branch the change is already on, and the manual cherry-pick instructions it hands the reader do not apply. Anyone reading the PR later sees a failure sitting under a completed backport.

Clearest instance is #3119. Labeled backport on 2026-06-27, merged on 2026-06-29. Its backport to release-1.5 opened as #3127 and merged at 2026-06-30T12:47:24Z. Fifty-three seconds later, at 12:48:17Z, backport-previous was added to #3119 to also send the change to release-1.4. At 12:48:33Z the bot posted "Backport failed for release-1.5, because it was unable to cherry-pick the commit(s)." on #3119, for a branch that had held the commit for under a minute.

The re-run itself is expected and not the bug. .github/workflows/backport.yaml:5 subscribes to pull_request_target types [closed, labeled], and the backport job at :116 runs a matrix over [current, previous] guarded by which labels are present. The second label re-enters the job for both targets, so the current leg cherry-picks commits release-1.5 already has. Two of those re-runs are already harmless, because the action recognises an existing backport branch and an existing backport PR and continues quietly. The third one is not.

The mechanism is in the action, not here. git cherry-pick -x <sha> onto a branch that already contains the change is empty rather than conflicting, and git still exits 1. The action reads exit 1 as a conflict, and under the draft_commit_conflicts setting this repository passes at .github/workflows/backport.yaml:155-158 it commits the working tree with git commit --all. Nothing is staged, so that exits 1 too, the action aborts the cherry-pick and posts the conflict failure comment. I reproduced both exit codes locally against git 2.55.0. Details and line references are in korthout/backport-action#457, which is where the fix belongs.

There is a local guard worth considering while that sits open, since the false comment is cheap to prevent from this side. The action's backport branch name is deterministic, backport-${pull_number}-to-${target_branch}, so the existing Set target branch step already knows the exact head branch a previous run would have used. Asking the API whether a PR with that head exists and is merged, then dropping that target from the matrix leg when it does, skips the re-run before it can misreport. A git-side alternative is git cherry <target> <sha>, which marks a patch-equivalent commit with - and answers the same question without caring how the earlier backport was merged. Both are small. Someone closer to the release flow should pick.

A guard here does not replace the upstream fix. It only covers the case where a prior backport PR exists under this repository's own naming. The "empty cherry-pick reported as a conflict" behaviour hits every consumer of the action and belongs upstream.

What I checked:

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug
    upstream-issueRequires resolving an issue in an upstream project
    area/ciIssues or PRs related to CI workflows, GitHub Actions, automation
    on Aug 6, 2026
  2. lexfrei commented on Sep 23, 2026

    @lexfrei
    ContributorAuthor

    The guard proposed here landed in #3616. backport.yaml now skips a target when backport-<pr>-to-<branch> is already merged. Reporting an empty pick as a conflict is still an upstream problem in korthout/backport-action#457.

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

    area/ciIssues or PRs related to CI workflows, GitHub Actions, automationkind/bugCategorizes issue or PR as related to a bugtriage/not-reproducibleIndicates an issue can not be reproduced as describedupstream-issueRequires resolving an issue in an upstream project

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions