Code owners rule is invalid when using a subgroup

Hi,

On my branch main-test I have CODEOWNERS file in the root of the repo with the rule /folder/ @group/subgroup.

I have a feature branch codeowners where I change the content of a file inside /folder/ and then I make a MR to merge into main-test but I get the following message on the MR UI:

Approval rule "/folder/" is invalid. GitLab has approved this rule automatically to unblock the merge request.

I also tried /folder/ @gitlab.com/group/subgroup but I get the same result.

If I use the rule /folder/ @group instead, it works, but what I want are the members of the subgroup and not the group.

Is this a bug or am I doing something wrong?

I also would like to know if it is possible to only add members owners and maintainers of a subgroup instead of every member?

Hi,

Here is documentation when rules are evaluated as invalid Invalid rules

You have not specified if your project is under group/subgroup or somewhere else, but in general there are several caveats for using groups in Codeowners. The group/subgroup must be a direct member of the project (using invite a group in the project) if the project is not in the group/subgroup. Also users must be direct members of the invited group, inherited membership won’t work for required approvals. Quite common is also that a Code Owner group has a visibility of private, and the current user is not a member of the Code Owner group.

I also would like to know if it is possible to only add members owners and maintainers of a subgroup instead of every member?

No, every member of a group is a valid approver. So a dedicated subgroups are usually created for approvers.

You can read more about it in Groups as Code Owners

That solved the issue, thanks!