Skip to content

Deleted Branch Rule Approval Rules Unexpectedly Transfer to All Branches

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

When deleting a branch rule that has associated approval rules, the approval rules are automatically transferred to "All branches" instead of being deleted or prompting for user input on how to handle them.

This was reported by customer - Zendesk Internal Only

Steps to reproduce

  1. Create a branch rule for a specific branch (e.g., branch-for-branch-rules)
  2. Add an approval rule to this branch rule
  3. Verify that the approval rule is correctly associated with the specific branch
  4. Delete the branch rule
  5. Observe that the approval rule is automatically moved to "All branches"

Example Project

What is the current bug behavior?

When a branch rule is deleted, any associated approval rules are automatically transferred to the "All branches" configuration without user notification or confirmation.

What is the expected correct behavior?

One of the following should occur:

  1. Approval rules should be deleted along with their associated branch rule
  2. User should be prompted to choose what happens to the approval rules (delete/keep/transfer)
  3. Approval rules should remain specific to the branch but marked as inactive

Relevant logs and/or screenshots

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Workaround

Currently, users must:

  1. Before deleting a branch rule, note any associated approval rules
  2. Delete the branch rule
  3. Manually remove the approval rules that were transferred to "All branches"
  4. Recreate any necessary approval rules in their intended location

Proposed Solution

  1. Short-term:

    • Add a confirmation dialog when deleting branch rules with associated approval rules
    • Provide options in the dialog for handling the approval rules
    • Add warning notifications about approval rule transfer
  2. Long-term:

    • Implement proper cleanup of associated approval rules
    • Add user preferences for handling orphaned approval rules
    • Improve UI feedback when approval rules are affected by branch rule changes
Edited by 🤖 GitLab Bot 🤖