Avoid creating approval rules from policies for unprotected branches
What does this MR do and why?
This MR solves a problem that existed when the user tried to create MR for non-protected branches, with group-level merge request approval policies defined.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
| Before | After |
|---|---|
![]() |
|
How to set up and validate locally
- Create new Group
- Create new Policy for the group:
name: Policy
description: Merge request policy to apply to all projects
enabled: true
actions:
- type: require_approval
approvals_required: 1
user_approvers_ids:
- 55
- 65
- 62
- 1
- type: send_bot_message
enabled: true
rules:
- type: any_merge_request
commits: any
branches:
- main
- type: any_merge_request
commits: any
branches:
- master
- type: any_merge_request
commits: any
branches:
- prod
- type: any_merge_request
commits: any
branches:
- production
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
policy_scope:
projects:
excluding: []
fallback_behavior:
fail: closed
- Create new project in that group
- Create new MR where both source and target branches are not protected
- Observe that approval is not required
Related to #503227 (closed)
Edited by Alan (Maciej) Paruszewski

