Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectMergeRequestApprovalManager.set_approvers cannot handle too many approval rules #2825

Closed
liu15 opened this issue Mar 19, 2024 · 0 comments · Fixed by #2866
Closed

Comments

@liu15
Copy link

liu15 commented Mar 19, 2024

Description of the problem, including code/CLI snippet

In v4/objects/merge_request_approvals.py ~ line 121

    # update any existing approval rule matching the name
    existing_approval_rules = approval_rules.list()
    for ar in existing_approval_rules:
        if ar.name == approval_rule_name:
            ar.user_ids = data["user_ids"]
            ar.approvals_required = data["approvals_required"]
            ar.group_ids = data["group_ids"]
            ar.save()
            return ar
    # if there was no rule matching the rule name, create a new one
    return approval_rules.create(data=data, **kwargs)

An existing approval rule will not be found if it exceeds the default pagination count for list(). It will instead attempt to create it (which will fail because it already exists)

Expected Behavior

approval rule should be found in the list of existing approval rules and be modified.

Actual Behavior

approval rule is not found and creation of new rule fails.

Specifications

I believe this fix is to change

approval_rules.list()

to

approval_rules.list(all=True)

  • python-gitlab version: 4.4.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com):
JohnVillalovos added a commit that referenced this issue May 15, 2024
Use `iterator=True` when going through the list of current approval
rules. This allows it to handle more than the default of 20 approval
rules.

Closes: #2825
nejch pushed a commit that referenced this issue May 17, 2024
Use `iterator=True` when going through the list of current approval
rules. This allows it to handle more than the default of 20 approval
rules.

Closes: #2825
nejch pushed a commit that referenced this issue May 17, 2024
Use `iterator=True` when going through the list of current approval
rules. This allows it to handle more than the default of 20 approval
rules.

Closes: #2825
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant