Skip to content

Cap the approval threshold at the users able to vote - #37648

Merged
shah-harshit merged 4 commits into
mainfrom
shah-harshit/approval-threshold-cap
Nov 12, 2026
Merged

shah-harshit merged 4 commits into
mainfrom
shah-harshit/approval-threshold-cap

Conversation

@shah-harshit

@shah-harshit shah-harshit commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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.resolveApprovalThreshold now caps the threshold at the number of assignees when every assignee is a user:

  • A list holding a team is not capped, because any number of its members can vote.
  • An empty list is not capped.
  • The allAssignees mode keeps raising the threshold to the entry count, then the same cap applies, so allAssignees with 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:

  • Bug fix

High-level design:

N/A, small change.

Tests:

Use cases covered

  • Owner + reviewer with threshold 2, the reviewer is the requester: the threshold becomes 1 and the owner's approval completes the task.
  • Two users with threshold 3: the threshold becomes 2.
  • A user plus a team: the threshold is left at 2.
  • No assignees: the threshold is left unchanged.

Unit tests

  • CreateTaskTest#approvalThresholdNeverExceedsTheUsersAbleToVote (new). It fails on the previous code: (null, 2, users(1)) returned 2.
  • Updated allAssigneesModeRaisesTheThresholdToTheEntryCount. The old allAssignees, 2, users(1) -> 2 case was the stuck shape, and the new test covers it.
  • CreateTaskTest#changeRequestPolicyNeverRequiresMoreApprovalsThanTheUsersAbleToVote: the change-request ReviewPolicy gets the same cap.
  • mvn test -pl openmetadata-service -Dtest=CreateTaskTest: 86/86 pass.

Backend integration tests

  • Not added. The change is a pure function of the configured threshold and the resolved assignees, and it is covered at unit level.

Manual testing

  1. Create a data contract workflow whose User Approval node has "Add owners" and "Add reviewers" on and threshold 2.
  2. Give a contract one owner (A) and one reviewer (B). As B, make a change that triggers the workflow.
  3. Before: A approves and the task stays open. After: A's approval completes the task.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>. No issue was filed; the customer report is described above.
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: not applicable.
  • For a UI feature or feature task: not applicable (backend fix).
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: I reviewed the final diff against REVIEW.md.
  • Decision check: adds docs/decisions/2026-11-12-approval-threshold-never-exceeds-eligible-voters.md.
  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code


Summary by Gitar

  • Change request policy:
    • Applied the same threshold cap to the change-request ReviewPolicy built by reviewPolicy in CreateTask

This will update automatically on new commits.

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]>
@shah-harshit
shah-harshit requested a review from a team as a code owner November 12, 2026 09:33
@shah-harshit
shah-harshit requested a review from pmbrull November 12, 2026 09:33
@shah-harshit shah-harshit added safe to test Add this label to run secure Github workflows on PRs backend labels Nov 12, 2026
@shah-harshit shah-harshit self-assigned this Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

The review policy attached to a change request still carried the node
threshold, so the only eligible reviewer's approval read as a disagreement.
@shah-harshit shah-harshit added the skip-pr-checks Bypass PR metadata validation check label Nov 12, 2026
List<EntityReference> assignees) {
return new ReviewPolicy()
.withApprovalThreshold(capAtUsersAbleToVote(nodeApprovalThreshold, assignees))
.withRejectionThreshold(rejectionThreshold)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. Data contract workflow, User Approval node with "Add owners" and "Add reviewers" on, approval threshold 2 and rejection threshold 2.
  2. The contract has owner A and reviewer B. B makes a change, so B is taken off the assignees.
  3. 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
@gitar-bot

gitar-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 1 closed / 1 findings

Capping 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

📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java:207-221 📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java:990-998
The capped value only reaches the Flowable approvalThreshold variable. ReviewPolicy (lines 207-210) is still built from the raw approvalThreshold and attached to the change request, and ChangeSelection.approvalThreshold(policy) and ReviewDisagreement.outOfReach read that policy. Take a change request decided change by change (catalogCounts) with a node threshold of 2, where the requester was removed and one user reviewer is left. When that reviewer approves, approvers(1) + undecided(0) < 2 and rejecters(0) + undecided(0) < 1 both hold. The change is treated as "reviewers could not agree" and is not published, even though the only eligible voter approved. In that case the variable is forced to 1, so the cap in this PR does nothing. This goes against what the new ADR says: "an approval task's threshold never exceeds the users able to vote." Fix: work out the capped threshold before building ReviewPolicy, use it in both places, and add a test for the change-request path.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@shah-harshit
shah-harshit enabled auto-merge (squash) November 12, 2026 10:28
@shah-harshit
shah-harshit merged commit 33ead2e into main Nov 12, 2026
64 of 65 checks passed
@shah-harshit
shah-harshit deleted the shah-harshit/approval-threshold-cap branch November 12, 2026 10:34
shah-harshit added a commit that referenced this pull request Nov 12, 2026
…#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.
shah-harshit added a commit that referenced this pull request Nov 12, 2026
…#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants