`Invalid` approval rule message is confusing
Problem to Solve
As part of #334698 (closed) a message was added to the approval widget when a rule is Invalid
:
Approval rule \[Rule 2\] is invalid. GitLab....
This message is confusing to users because it doesn't explain why an approval rule might be invalid or what a user would need to do about it.
More details
We seem to be exposed to this a bit more within GitLab the company because of how we've set up our CODEOWNER rules.It looks like there are two scenarios where users keep reporting this error:1. Excluding docs from approvals
We set this up as a sort of hack to exclude documentation-only changes from requiring any approvals. This isn't exactly "valid" syntax which is why it shows a warning and auto-approves.
Proposal: We should look into Exempt specific files from Codeowners rules (#41914) to add a valid method to exclude certain files/paths from approvals.
2. Group isn't a member of the project
This came up at least once. The approval group weren't actually project members so the rule was auto-approved. This was fixed by adding the group as project members.
Proposal: I'm not too sure. Do we have the information to create a relevant error message? Something like <rule> is invalid because the approval group does not belong to the project.
would've been far more useful but I'm not sure if it's actually possible
Additional Details
This has been mentioned several times in Slack recently:
Proposal
- In the approvals' widget, update the message to:
-
If 1 invalid rule:
1 invalid rule has been approved automatically, as no one can approve it.
-
If more than 1 invalid rule:
{#number_of_rules} invalid rules have been approved automatically, as no one can approve them.
-
- In the widget details section, add a popover to the
(?)
icon in each invalid rule row with this content (and links):
Why is this rule invalid?
This rule is invalid because no one can approve it:
- It doesn't have any eligible approvers.
- Or approval settings prevent approvals by its eligible approvers.
Invalid rules are automatically approved to unblock the merge request.
Testing
New feature/specs to be added to check the different types on invalid rules and associated messages. If this is not feasible, an additional E2E test may need to be added.
Also, this frontend test will need to be updated: https://gitlab.com/gitlab-org/gitlab/-/blob/master/spec/frontend/vue_merge_request_widget/components/approvals/approvals_spec.js#L405