Skip to content

Conversation

@Prucek
Copy link
Member

@Prucek Prucek commented Oct 30, 2025

Fixes #269
When a PR has "changes requested", Tide was attempting to merge it even though GitHub blocks it when branch protection requires reviews.
Changes:

  • Added branch protection check in isAllowedToMerge() to block merges only when branch protection requires reviews and the PR has "changes requested"
  • Updated requirementDiff() to respect branch protection settings for status messages
  • Added branchRequiresReviews() helper with caching to minimize API calls

Result: Tide no longer attempts to merge PRs with "changes requested" when branch protection would block the merge.
🤖 Assisted by Claude.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 30, 2025
@netlify
Copy link

netlify bot commented Oct 30, 2025

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit 854b8a8
🔍 Latest deploy log https://app.netlify.com/projects/k8s-prow/deploys/6904a5b76a69b7000837e066
😎 Deploy Preview https://deploy-preview-537--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Prucek
Once this PR has been reviewed and has the lgtm label, please assign cjwagner for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the area/tide Issues or PRs related to prow's tide component label Oct 30, 2025
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 30, 2025
@petr-muller
Copy link
Contributor

/cc

Copy link
Contributor

@petr-muller petr-muller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some good news and bad news here ;)

Good news: the requirementDiff test coverage alone is an excellent contribution and I'd like to get it merged no matter what, likely separately from the actual attempted fix (see the bad news).

Bad news: I do not think this actually resolves the underlying problem. The requirementDiff method is used in Tide's status-managing controller (the one that manages the GH status context on the PR commit, including the message shown on the commit) but not in the controller that actually manages mergeability decisions and attempts merge. There are some notes on this in the linked issue.


if q.ReviewApprovedRequired && pr.ReviewDecision != githubql.PullRequestReviewDecisionApproved {
// PullRequestReviewDecisionChangesRequested is similar to not approved
if pr.ReviewDecision == githubql.PullRequestReviewDecisionChangesRequested {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if this was sufficient to fix the issue (which I'm afraid it isn't :( ), would this always be correct to do? I believe that "prevent PRs from merge if there are changes requested" is actually configurable behavior (part of branch protection), so depending on what the repository has configured (and I think also depending on who authored the "request changes" review - maybe that part is propagated to the pr.ReviewDecision here though) such review may or may not block merging, but here we'd treat it as if such branch protection was always enabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, understood. So now, when I get that info from branch protection and update the isAllowedToMerge that should work?

Copy link
Contributor

@petr-muller petr-muller Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it's complicated under that "get that info from branch protection" sentence. "Will this PR be mergeable per all GitHub-side configuration" is a complicated problem, because branch protection is now actually two kinds of GH-side concepts (rulesets -- new thing and protected branches -- old thing). And both are not trivial to intepret. Getting info from branch protection would mean you'd need to interpret them, basically reverse engineering GH functionality, in Tide which I believe is not sustainable. It may not be that hard to do for specific merge-blocking setting (like "changes requested" here) but the whole thing would become a whack-a-mole where various GH-side settings prevent PRs from merging, and Tide would need to learn all of them them.

I believe the suitable medium-term approach is to improve how this whole class of failure cases is surfaced. One of the main problems today is that when you hit any case where Tide thinks something is mergeable but GH prohibits that (basically whenever you hit this place), it is not surfaced to the user in any way. The user will see something like a green dot saying In merge pool and Tide will be logging these "user errors" in its log.

If we could somehow improve this behavior in general (no matter what the actual reason GH has for disallowing the merge), it would benefit this whole class of failure cases, and we would have more space to experiment with how to make Tide play better with these GH concepts.

Obtaining GH-side information for each merge attempt has its flaws, too; it is API-intensive (although it can be cached, like you are doing in the current revision) and imagine doing these checks for every cause that can prevent the merge.

One additional thought I have is whether GH surfaces the result of its mergeability checking machine somethow through APIs available to Tide. The GitHub UI itself can disable (grey-out) the merge button if the PR does not meet the mergeability criteria - this means GH is able to expose the data at least to its UI. Now the question is whether this is also exposed through the public APIs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some breadcrumbs on:

whether GH surfaces the result of its mergeability checking machine somethow through APIs available to Tide

  1. There is something called mergeable_state in the v3 PR API; we do not seem to use that at all (we use mergeable which AFAIK surfaces the git-level mergeability). It is not documented in https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28&versionId=free-pro-team%40latest&category=pulls (at least I have not ofund anything relevant but it is listed in the example API responses)
  2. v4 docs have something called MergeStateStatus which looks worth looking into: https://docs.github.com/en/graphql/reference/enums#mergestatestatus

Sources: I interrogated Claude Code which then lead me to the follwoing links:

@petr-muller
Copy link
Contributor

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 30, 2025
@Prucek Prucek changed the title tide: changes requested block merge tide: changes requested block merge when branch protection requires reviews Oct 31, 2025
@petr-muller
Copy link
Contributor

Conversation from #537 (comment) aside, I am not opposed to trying to improve it for this specific case with the approach you are trying, and I will review the code as it is now.

What kind of testing have you done on this? Have you tried reproducing the failure case from the linked issue and verifying the modified Tide really improves the behavior as expected?

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

Labels

area/tide Issues or PRs related to prow's tide component cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PR with "Change requested" leads to Tide repeatedly attempting MERGE

3 participants