Repository navigation
Cap the approval threshold at the users able to vote - #37648
Conversation
Self-approval prevention removes the requester from the assignees, so a fixed threshold could exceed the remaining voters and leave the task open forever (e.g. owner + reviewer, threshold 2, reviewer made the change). Co-Authored-By: Claude Opus 5.5 <[email protected]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
The review policy attached to a change request still carried the node threshold, so the only eligible reviewer's approval read as a disagreement.
| List<EntityReference> assignees) { | ||
| return new ReviewPolicy() | ||
| .withApprovalThreshold(capAtUsersAbleToVote(nodeApprovalThreshold, assignees)) | ||
| .withRejectionThreshold(rejectionThreshold) |
There was a problem hiding this comment.
The rejection threshold has the same problem and isn't capped. handleMultiApproval in WorkflowHandler only rejects once rejectionCount >= rejectionThreshold, and nothing ends a task that can no longer reach either threshold. So when the requester is removed from the assignees, a rejection threshold of 2 can't be reached by the one person left, and the task stays open just like before.
Steps to reproduce:
- Data contract workflow, User Approval node with "Add owners" and "Add reviewers" on, approval threshold 2 and rejection threshold 2.
- The contract has owner A and reviewer B. B makes a change, so B is taken off the assignees.
- A rejects.
The task now shows 1 of 2 rejections with nobody left to vote, and it never closes.
Can we cap the rejection threshold the same way in this PR: here in reviewPolicy, and where notify sets the rejectionThreshold task variable? The 2.0 and 2.1 backports need the same change, plus a test for the reject case. The decision record's "a task can always complete" only holds once both thresholds are capped.
There was a problem hiding this comment.
Good catch, fixed in e2f2f60. The rejection threshold now gets the same cap (CreateTask.capAtUsersAbleToVote) in both places: the rejectionThreshold task variable in notify, and reviewPolicy. Added rejectionThresholdNeverExceedsTheUsersAbleToVote, which covers your repro shape (thresholds 2/2, one user left, so the cap is 1) plus the team and empty-list cases. Same change in the backports: 2.1 #37651 (127ca4d), and 2.0 #37650 (3d1a824), where the helper is renamed from capApprovalThreshold to capAtUsersAbleToVote since it now covers both thresholds.
I reworded the decision record's "a task can always complete" in all three. It now says both thresholds stay reachable, and it calls out that a split vote can still leave a task open (two voters, thresholds 2/2, one approves and one rejects). That stalemate predates this PR and isn't changed by it. Happy to handle it separately if you want.
With the requester removed, a rejection threshold above the remaining voters could never be met either, leaving a rejected task open.
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findingsCapping approval and rejection thresholds may let workflow changes proceed with fewer independent votes than configured, reducing governance safeguards. Caps the User Approval task threshold at the number of user assignees so a task no longer stays open when fewer voters remain than the threshold requires; teams and empty lists are left uncapped. The change-request ReviewPolicy gap was resolved by applying the same cap there. No open issues found. ✅ 1 closed✅ Bug: Change-request ReviewPolicy still gets the uncapped node threshold
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
…#37650) * fix(workflows): cap approval threshold at the users able to vote Self-approval prevention removes the requester from the assignees, so a fixed threshold could exceed the remaining voters and leave the task open forever (e.g. owner + reviewer, threshold 2, reviewer made the change). Backport of #37648 to 2.0. * docs(decisions): align approval threshold cap records with this branch * fix(workflows): cap the rejection threshold at the users able to vote With the requester removed, a rejection threshold above the remaining voters could never be met either, leaving a rejected task open.
…#37651) * fix(workflows): cap approval threshold at the users able to vote Self-approval prevention removes the requester from the assignees, so a fixed threshold could exceed the remaining voters and leave the task open forever (e.g. owner + reviewer, threshold 2, reviewer made the change). Backport of #37648 to 2.1. * fix(workflows): cap the change-request review policy threshold too The review policy attached to a change request still carried the node threshold, so the only eligible reviewer's approval read as a disagreement. * docs(decisions): align approval threshold cap records with this branch * fix(workflows): cap the rejection threshold at the users able to vote With the requester removed, a rejection threshold above the remaining voters could never be met either, leaving a rejected task open.
Describe your changes:
A User Approval task could stay open forever when the approval threshold was higher than the number of users left to vote.
Reported by a customer on 2.0.7: a data contract workflow's User Approval node had "Add owners" and "Add reviewers" on, with an approval threshold of 2. The contract had one owner and one reviewer. When the reviewer made the change, self-approval prevention (
SetApprovalAssigneesImpl) correctly removed them from the assignees. That left one assignee against a threshold of 2. After the owner approved, the task stayed open with nobody left to vote, and the contract could not move forward.CreateTask.resolveApprovalThresholdnow caps the threshold at the number of assignees when every assignee is a user:allAssigneesmode keeps raising the threshold to the entry count, then the same cap applies, soallAssigneeswith threshold 2 and one user no longer gets stuck.Why not count the requester's change as their approval? That is self-approval under another name: a reviewer could make the change and be one of the two approvers. The cap is honest about what happened. One independent person approved, and the task records a threshold of 1. A workflow that needs two independent approvals in this case has to name enough approvers (a team, a third reviewer, or the admin fallback).
The rejection threshold gets the same cap, so the one remaining voter can also reject. A split vote (two voters, thresholds 2/2, one approves and one rejects) can still leave a task open; that predates this change.
Limit: the cap applies when the task is created. Tasks that are already open keep the threshold they started with.
Decision record:
ADR:2026-11-12-approval-threshold-never-exceeds-eligible-voters.Backports: #37650 (2.0), #37651 (2.1).
Type of change:
High-level design:
N/A, small change.
Tests:
Use cases covered
Unit tests
CreateTaskTest#approvalThresholdNeverExceedsTheUsersAbleToVote(new). It fails on the previous code:(null, 2, users(1))returned 2.allAssigneesModeRaisesTheThresholdToTheEntryCount. The oldallAssignees, 2, users(1) -> 2case was the stuck shape, and the new test covers it.CreateTaskTest#changeRequestPolicyNeverRequiresMoreApprovalsThanTheUsersAbleToVote: the change-requestReviewPolicygets the same cap.mvn test -pl openmetadata-service -Dtest=CreateTaskTest: 86/86 pass.Backend integration tests
Manual testing
Checklist:
Fixes <issue-number>: <short explanation>. No issue was filed; the customer report is described above.Fixes #<issue-number>above.REVIEW.md.docs/decisions/2026-11-12-approval-threshold-never-exceeds-eligible-voters.md.🤖 Generated with Claude Code
Summary by Gitar
ReviewPolicybuilt byreviewPolicyinCreateTaskThis will update automatically on new commits.