Skip to content

Update approval rules name validation to include approval policy

What does this MR do and why?

This MR fixes the validation on name in approval_project_rules & approval_merge_request_rules to include the any_merge_request and license_scanning report type too.

The bug happens when an approval policy is created with multiple approvers and with any_merge_request rule type, the approval rules are created with same name with different approval_policy_action_idx. Since the validation only includes scan_finding type, the any_merge_request rules creation fails.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

  • Create a project or group and create an approval policy to require approval on any MR with 3 different approval actions
approval_policy:
  - name: Any MR Rule
    description: ''
    enabled: true
    policy_scope:
      projects:
        excluding: []
    rules:
      - type: any_merge_request
        branch_type: protected
        commits: any
    actions:
      - type: require_approval
        approvals_required: 1
        role_approvers:
          - maintainer
      - type: require_approval
        approvals_required: 1
        user_approvers_ids:
          - <user id>
      - type: require_approval
        approvals_required: 1
        group_approvers_ids:
          - <group id>
      - type: send_bot_message
        enabled: true
    approval_settings:
      block_branch_modification: true
      block_group_branch_modification: true
      prevent_pushing_and_force_pushing: true
      prevent_approval_by_author: true
      prevent_approval_by_commit_author: true
      remove_approvals_with_new_commit: true
      require_password_to_approve: false
    fallback_behavior:
      fail: closed
  • Create an MR in the project (within the group if the policy is created at group) and observe that there are 3 approvals required

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sashi Kumar Kumaresan

Merge request reports

Loading