sorenlouv / backport

A simple CLI tool that automates the process of backporting commits on a GitHub repo
https://github.com/sqren/backport/blob/main/docs/config-file-options.md
Apache License 2.0
241 stars 57 forks source link

`No target branches found for this PR` error #475

Closed jumaffre closed 9 months ago

jumaffre commented 10 months ago

First, thank you very much for this tool/GHA, which has been saving us many manual operations backporting commits to release branches 💯

We've started seeing the following error in our GitHub Actions pipeline:

Run sqren/backport-github-action@main
Initiate backport
{"optionsFromGithub":{"authenticatedUsername":"ccf-bot","sourceBranch":"main","isRepoPrivate":false,"repoOwner":"microsoft","repoName":"ccf","targetBranchChoices":["release/3.x","release/4.x"],"branchLabelMapping":{"^(.+)-todo$":"release/$1"},"autoMerge":true,"autoMergeMethod":"squash","prTitle":"[{{targetBranch}}] Cherry pick: {{commitMessages}}","prDescription":"Backports the following commits to `{{targetBranch}}`:\n{{commitMessages}}","sourcePRLabels":["backported"],"targetPRLabels":["$1-backport"],"autoAssign":false,"publishStatusCommentOnSuccess":false,"publishStatusCommentOnFailure":true,"publishStatusCommentOnAbort":true},"actionOptions":{"accessToken":"***","assignees":["jumaffre"],"gitHostname":"github.com","githubActionRunId":6073[5](https://github.com/microsoft/CCF/actions/runs/6073526987/job/16475609988#step:5:6)2[6](https://github.com/microsoft/CCF/actions/runs/6073526987/job/16475609988#step:5:7)987,"githubApiBaseUrlV3":"https://api.github.com/","githubApiBaseUrlV4":"https://api.github.com/graphql","interactive":false,"publishStatusCommentOnFailure":true,"pullNumber":560[7](https://github.com/microsoft/CCF/actions/runs/6073526987/job/16475609988#step:5:8),"repoForkOwner":"microsoft","repoName":"CCF","repoOwner":"microsoft","reviewers":[]}}
{"commits":[{"author":{"name":"Julien Maffre","email":"42961061+jumaffre@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-09-04T12:39:07Z","message":"Update `llhttp` from `6.0.9` to `9.0.1` (#5607)","sha":"25b6efc252da177492e4b9c8063ced70fe6c8989","branchLabelMapping":{"^(.+)-todo$":"release/$1"}},"sourcePullRequest":{"labels":["auto-backport","4.x-todo"],"title":"Update `llhttp` from `6.0.9` to `9.0.1`","number":5607,"url":"https://github.com/microsoft/CCF/pull/5607","mergeCommit":{"message":"Update `llhttp` from `6.0.9` to `9.0.1` (#5607)","sha":"25b6efc252da177492e4b9c[8](https://github.com/microsoft/CCF/actions/runs/6073526987/job/16475609988#step:5:9)063ced70fe6c8989"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"release/4.x","label":"4.x-todo","branchLabelMappingKey":"^(.+)-todo$","isSourceBranch":false,"state":"NOT_CREATED"}]}]}
Error: Backport failure: No target branches found for this PR. Aborting.
Error: No target branches found for this PR. Aborting.

This used to work fine before (last successful run 2 weeks ago) and we haven't updated our .backportrc.json apart from the breaking change in the template engine.

I also can't find anything obvious in the commit history on this repo that could have caused this issue. Do you know what could have caused this?

sorenlouv commented 10 months ago

Hi there,

Thanks for the kind words.

What version are you using and did the problem start occuring after you upgraded?

sorenlouv commented 10 months ago

... ah, I see you are on the main branch. Will take a look

achamayou commented 10 months ago

@sqren it looks like the action is now trying to backport to a hypothetical "foo" branch: https://github.com/microsoft/CCF/pull/5618#issuecomment-1707059214

Echoing what @jumaffre has already said, we are very grateful, backport is a huge time saver for us!

sorenlouv commented 10 months ago

I am not 100% sure why this is happening. I have a theory that because the backport action runs immediately after the pull request is merged, the Github API doesn't always reflect the true state yet, which leads the backport tool into an invalid state. Or, it could just be a bug on my end 🤷

Either way, I recently added a check to prevent the action from starting, if there are no branches to backport to. I've reverted that in https://github.com/sqren/backport-github-action/pull/110/files#diff-69c9100f2a3041c22e8fddf77d13fd7eb1aa42a8a200aa35a81ea589c135e66a and hope that solves the problem.

Let me know if this comes up again!

sorenlouv commented 10 months ago

@sqren it looks like the action is now trying to backport to a hypothetical "foo" branch: microsoft/CCF#5618 (comment)

My bad! Talk about testing in production 😱 I was trying to repro your problem, and that caused the noise on the PR (I've deleted the comments)

achamayou commented 10 months ago

@sqren it looks like the action is now trying to backport to a hypothetical "foo" branch: microsoft/CCF#5618 (comment)

My bad! Talk about testing in production 😱 I was trying to repro your problem, and that caused the noise on the PR (I've deleted the comments)

No harm done :) Thank you for looking into this and adding the check, the action is working as expected now as far as I can tell: https://github.com/microsoft/CCF/pull/5618#issuecomment-1707850500 (there's a merge conflict, but that's unrelated).

jumaffre commented 9 months ago

Closing this issue as our backport pipeline is now working. Thank you @sqren!