chdsbd / kodiak

🔮 A bot to automatically update and merge GitHub PRs

Home Page:https://kodiakhq.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kodiak randomly closed a pull request

scriptnull opened this issue · comments

We noticed that kodiak randomly closed a pull request in a repo (precisely 23 hours ago). The pull request didn't contain any labels that kodiak config makes use of. Did something change recently in kodiak that we can relate this to?

Can you paste your Kodiak config?

Also, can you paste a screenshot of your branch protection rules?

Was the pull request's base branch deleted? Kodiak doesn't have logic to close pull requests, but it will delete branches if configured.

I wonder if a branch was deleted and that closed a related PR.

Also, can you provide a URL for the PR that was closed unintentionally?

Additionally, I happened to know this information from the author of the PR which might help in debugging this: They seem to have reused a branch name for opening this pull request that had already been merged and reverted.

(maybe you could relate it to a situation where Kodiak is looking at the branch name of the PR and notices that there is already a pull request that is merged for that branch and so closes and deletes the PR)

Also, if you still need the above information that you requested, could you share an email to which I could drop them?

Hey @scriptnull, can you send an email to support@kodiakhq.com and I can ask for more info

@scriptnull The only case I could see where Kodiak might cause a PR to be closed is when the merge.delete_branch_on_merge setting is enabled. In this case, Kodiak will delete the branch if there are no other dependent PRs.

Here's the related code:

if pull_request.state == PullRequestState.MERGED:
log.info(
"pull request merged. config.merge.delete_branch_on_merge=%r",
config.merge.delete_branch_on_merge,
)
await api.dequeue()
if (
not config.merge.delete_branch_on_merge
or pull_request.isCrossRepository
or repository.delete_branch_on_merge
):
return
pr_count = await api.pull_requests_for_ref(ref=pull_request.headRefName)
# if we couldn't access the dependent PR count or we have dependent PRs
# we will abort deleting this branch.
if pr_count is None or pr_count > 0:
log.info(
"skipping branch deletion because of dependent PRs", pr_count=pr_count
)
return
await api.delete_branch(branch_name=pull_request.headRefName)
return

A simple workaround might be to disable that setting and use the built in "Automatically delete head branches" GitHub repository setting.