[go: up one dir, main page]

Group branch rule update fails with permission error

Summary

Updating a group branch rule from the Branch rule page fails with "Something went wrong while updating branch rule." error message.

Implementation plan

backend

  • Extend BranchProtection interface to include indicator of where the rule was created. This could be
    • protectionLevel: String with values group or project
    • inherited: Boolean

frontend

  • add visual indicator to protected branches section on a project branch rule details page. This will show if a protection was created on a group level.
  • disable editing of protected branch section for group level rule.

Steps to reproduce

  1. Navigate to a top-level group's Settings > Repository
  2. Expand "Protected branches" section
  3. Select "Add protected branch"
  4. Create a protected branch rule (e.g., branch name: main, configure merge/push permissions)
  5. Select "Protect" to save the rule
  6. Navigate to Settings > Repository and expand "Branch rules" section
  7. Select "View details" on the created branch rule
  8. Make changes to any branch rule settings (e.g., modify merge permissions)
  9. Attempt to save the changes

Actual result

  • User sees error message: "Something went wrong while updating branch rule."
  • The GraphQL mutation branchRuleUpdate returns permission error

Expected result

  • Branch rule should be successfully updated
  • Success message should be displayed

Design proposal

See #555424 (comment 2669177163)

🎨 Figma

Location Scenario Popover text Screen
Settings > Repository > Branch rules User DOES NOT have permission to edit group-level Protected branches Title: "Setting inherited"
Body: "This setting is configured for the group. To make changes, contact a user with the required permissions."
user does NOT have permission to edit group level.jpg
Settings > Repository > Branch rules User DOES have permission to edit group-level Protected branches Title: "Setting inherited"
Body: "This setting is configured for the group. To make changes, go to your group's repository settings."
user DOES have permission to edit group level.jpg
Settings > Merge requests > Approval settings Title: "Setting inherited"
Body: "This setting is configured for the instance. To make changes, contact your administrator."
mr.jpg

Relevant logs and/or screenshots

image

GraphQL Error Response:

{
    "errors": [
        {
            "message": "The resource that you are attempting to access does not exist or you don't have permission to perform this action",
            "locations": [
                {
                    "line": 2,
                    "column": 3
                }
            ],
            "path": [
                "branchRuleUpdate"
            ]
        }
    ],
    "data": {
        "branchRuleUpdate": null
    }
}

GraphQL Query:

mutation editBrachRuleEE($input: BranchRuleUpdateInput!) {
  branchRuleUpdate(input: $input) {
    errors
    branchRule {
      id
      name
      branchProtection {
        allowForcePush
        codeOwnerApprovalRequired
        mergeAccessLevels {
          nodes {
            accessLevel
            accessLevelDescription
            user {
              id
              typename
            }
            group {
              id
              typename
            }
            typename
          }
          typename
        }
        pushAccessLevels {
          nodes {
            accessLevel
            accessLevelDescription
            user {
              id
              typename
            }
            group {
              id
              typename
            }
            deployKey {
              id
              typename
            }
            typename
          }
          typename
        }
        typename
      }
      typename
    }
    typename
  }
}

Environment

  • GitLab version: GitLab.com
  • Browser: Any browser

Additional Notes

This issue only occurs with branch rules created at the group level. Branch rules created at the project level can be updated without errors.

Edited by 🤖 GitLab Bot 🤖