Skip to content

Backport to 2.0: cap the approval threshold at the users able to vote - #37650

Merged
shah-harshit merged 3 commits into
2.0from
shah-harshit/approval-threshold-cap-2.0
Nov 12, 2026
Merged

shah-harshit merged 3 commits into
2.0from
shah-harshit/approval-threshold-cap-2.0

Conversation

@shah-harshit

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

Copy link
Copy Markdown
Contributor

Describe your changes:

Backport of #37648 to 2.0.

A User Approval task could stay open forever when the approval threshold was higher than the number of users left to vote. A customer on 2.0.7 hit this: a data contract with one owner and one reviewer had threshold 2. When the reviewer made the change, self-approval prevention removed them from the assignees. After the owner approved, nobody was left to vote and the task stayed open.

The threshold is now capped at the number of assignees when every assignee is a user. A list holding a team, and an empty list, are not capped. The requester's change is not counted as an approval, because that would be self-approval. Details and rationale are in #37648 and ADR:2026-11-12-approval-threshold-never-exceeds-eligible-voters.

2.0 has no resolveApprovalThreshold (added on 2.1 with the allAssignees mode), so this adds CreateTask.capApprovalThreshold and applies it where the task's approvalThreshold variable is set. Same rule, same decision record.

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 their threshold.

Type of change:

  • Bug fix

Tests:

  • CreateTaskTest#approvalThresholdNeverExceedsTheUsersAbleToVote
  • mvn test -pl openmetadata-service -Dtest=CreateTaskTest,UserApprovalTaskTest on this branch: 71/71 pass.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: carries docs/decisions/2026-11-12-approval-threshold-never-exceeds-eligible-voters.md.

🤖 Generated with Claude Code

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.
@shah-harshit
shah-harshit requested a review from a team as a code owner November 12, 2026 09:40
@shah-harshit
shah-harshit requested review from TeddyCr and removed request for a team November 12, 2026 09:40
@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.

@shah-harshit shah-harshit added the skip-pr-checks Bypass PR metadata validation check label Nov 12, 2026
With the requester removed, a rejection threshold above the remaining
voters could never be met either, leaving a rejected task open.
@shah-harshit
shah-harshit enabled auto-merge (squash) November 12, 2026 10:28
Comment on lines +1310 to +1314
* An approval or rejection threshold never exceeds the number of users able to vote. The requester is removed from
* the assignees to prevent self-approval, so a node requiring two approvals from an owner and a
* reviewer would otherwise leave the task open forever when the reviewer made the change. A list
* holding a team is not capped, since any number of its members can vote.
* ADR:2026-11-12-approval-threshold-never-exceeds-eligible-voters

@gitar-bot gitar-bot Bot Nov 12, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Quality: Reworded Javadoc line exceeds 100 columns; spotless:check will fail

In the rewritten Javadoc for capAtUsersAbleToVote, line 1310 is now about 118 characters long. google-java-format reflows Javadoc to 100 columns, so mvn spotless:check will flag this file. The repo guidelines require mvn spotless:apply before merging, and this PR has skip-pr-checks, so CI may not catch it before merge. Run mvn spotless:apply -pl openmetadata-service or rewrap the comment by hand.

Rewrap the Javadoc to 100 columns (or run mvn spotless:apply).:

/**
 * An approval or rejection threshold never exceeds the number of users able to vote. The
 * requester is removed from the assignees to prevent self-approval, so a node requiring two
 * approvals from an owner and a reviewer would otherwise leave the task open forever when the
 * reviewer made the change. A list holding a team is not capped, since any number of its members
 * can vote. ADR:2026-11-12-approval-threshold-never-exceeds-eligible-voters
 */

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 🔴 High risk 1 closed / 2 findings

Capping approval thresholds at eligible user assignees could let workflows advance with fewer independent approvals than configured.

Caps the User Approval task threshold (and rejection threshold) at the number of assignees when all assignees are users, so tasks can no longer stay open when too few voters remain. Resolved the ADR referencing a nonexistent resolveApprovalThreshold on 2.0.

  • Open minor finding: a reworded Javadoc line in CreateTask.java (around line 1310) exceeds 100 columns, so mvn spotless:check will fail. Run mvn spotless:apply -pl openmetadata-service or rewrap the comment.
💡 Quality: Reworded Javadoc line exceeds 100 columns; spotless:check will fail

📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java:1310-1314

In the rewritten Javadoc for capAtUsersAbleToVote, line 1310 is now about 118 characters long. google-java-format reflows Javadoc to 100 columns, so mvn spotless:check will flag this file. The repo guidelines require mvn spotless:apply before merging, and this PR has skip-pr-checks, so CI may not catch it before merge. Run mvn spotless:apply -pl openmetadata-service or rewrap the comment by hand.

Rewrap the Javadoc to 100 columns (or run mvn spotless:apply).
/**
 * An approval or rejection threshold never exceeds the number of users able to vote. The
 * requester is removed from the assignees to prevent self-approval, so a node requiring two
 * approvals from an owner and a reviewer would otherwise leave the task open forever when the
 * reviewer made the change. A list holding a team is not capped, since any number of its members
 * can vote. ADR:2026-11-12-approval-threshold-never-exceeds-eligible-voters
 */
✅ 1 closed
✅ Quality: ADR names CreateTask.resolveApprovalThreshold, which doesn't exist on 2.0

📄 docs/decisions/2026-11-12-approval-threshold-never-exceeds-eligible-voters.md:17 📄 openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java:1315
The Decision section of the backported ADR says CreateTask.resolveApprovalThreshold lowers the threshold. On 2.0 that method doesn't exist (the PR description says it was added in 2.1). The rule here is in CreateTask.capApprovalThreshold. The ADR is the record the code comment's ADR: tag points to, so anyone following it from the 2.0 branch will look for a method that isn't there. Change the ADR to name capApprovalThreshold on this branch, or say that 2.0 uses capApprovalThreshold in place of resolveApprovalThreshold.

🤖 Prompt for agents
Code Review: Caps the User Approval task threshold (and rejection threshold) at the number of assignees when all assignees are users, so tasks can no longer stay open when too few voters remain. Resolved the ADR referencing a nonexistent `resolveApprovalThreshold` on 2.0.
  
  - Open minor finding: a reworded Javadoc line in `CreateTask.java` (around line 1310) exceeds 100 columns, so `mvn spotless:check` will fail. Run `mvn spotless:apply -pl openmetadata-service` or rewrap the comment.

1. 💡 Quality: Reworded Javadoc line exceeds 100 columns; spotless:check will fail
   Files: openmetadata-service/src/main/java/org/openmetadata/service/governance/workflows/elements/nodes/userTask/CreateTask.java:1310-1314

   In the rewritten Javadoc for `capAtUsersAbleToVote`, line 1310 is now about 118 characters long. google-java-format reflows Javadoc to 100 columns, so `mvn spotless:check` will flag this file. The repo guidelines require `mvn spotless:apply` before merging, and this PR has `skip-pr-checks`, so CI may not catch it before merge. Run `mvn spotless:apply -pl openmetadata-service` or rewrap the comment by hand.

   Fix (Rewrap the Javadoc to 100 columns (or run mvn spotless:apply).):
   /**
    * An approval or rejection threshold never exceeds the number of users able to vote. The
    * requester is removed from the assignees to prevent self-approval, so a node requiring two
    * approvals from an owner and a reviewer would otherwise leave the task open forever when the
    * reviewer made the change. A list holding a team is not capped, since any number of its members
    * can vote. ADR:2026-11-12-approval-threshold-never-exceeds-eligible-voters
    */

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 merged commit 0ebc9e0 into 2.0 Nov 12, 2026
63 of 68 checks passed
@shah-harshit
shah-harshit deleted the shah-harshit/approval-threshold-cap-2.0 branch November 12, 2026 10:34
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