Search bar shows limited and inconsistent results when searching for groups
Summary
We have the ability to add groups as approvers for Merge Request approval rules. However, it doesn't always work consistently, especially with top-level groups or large sub-groups.
The search is performing a REST API query utilizing the groups API endpoint:
https://gitlab.com/api/v4/groups.json?search=gitlab-gold&per_page=20&all_available=true
If I were searching for the top-level group, for example, I wouldn't be able to find it as we're limiting the front end results to 20. If you query the API directly and change the per_page parameter or use top_level_only=true, you'll be able to find the results you are looking for. In the example below, I searched for the group gitlab-gold as an approver but due to the amount of subgroups and projects in this namespace, the actual group gitlab-gold doesn't display.
[{id: 11194381, web_url: "https://gitlab.com/groups/gitlab-gold/nfriend-test-gold-group",…},…]
0: {id: 11194381, web_url: "https://gitlab.com/groups/gitlab-gold/nfriend-test-gold-group",…}
1: {id: 10943443,…}
2: {id: 10943435,…}
3: {id: 7889310, web_url: "https://gitlab.com/groups/gitlab-com/support/1-1s", name: "1-1s", path: "1-1s",…}
4: {id: 12795900, web_url: "https://gitlab.com/groups/gitlab-gold/briecarranza/tickets/1195",…}
5: {id: 10943440,…}
6: {id: 11783568, web_url: "https://gitlab.com/groups/gitlab-gold/nilanka-test-group/206849-group",…}
7: {id: 11897863, web_url: "https://gitlab.com/groups/gitlab-gold/briecarranza/experimental/209220",…}
8: {id: 12129092, web_url: "https://gitlab.com/groups/gitlab-gold/briecarranza/tickets/213378",…}
9: {id: 13094878, web_url: "https://gitlab.com/groups/gitlab-gold/briecarranza/tickets/228769",…}
10: {id: 13285017, web_url: "https://gitlab.com/groups/gitlab-gold/briecarranza/experimental/232144",…}
11: {id: 13713534, web_url: "https://gitlab.com/groups/gitlab-gold/244201-test-group",…}
12: {id: 15461210, web_url: "https://gitlab.com/groups/gitlab-gold/261829", name: "261829", path: "261829",…}
13: {id: 15461956, web_url: "https://gitlab.com/groups/gitlab-gold/261829/261829-sub1",…}
14: {id: 15461957, web_url: "https://gitlab.com/groups/gitlab-gold/261829/261829-sub1/261829-sub2",…}
15: {id: 16779488, web_url: "https://gitlab.com/groups/gitlab-gold/272277-test", name: "272277-test",…}
16: {id: 32191313, web_url: "https://gitlab.com/groups/gitlab-gold/272640-test", name: "272640-test",…}
17: {id: 31321351, web_url: "https://gitlab.com/groups/gitlab-gold/275662-tmike", name: "275662-tmike",…}
18: {id: 12807414, web_url: "https://gitlab.com/groups/gitlab-silver/cbledsoe-test/2nd-level-sub-group",…}
19: {id: 7210496, web_url: "https://gitlab.com/groups/gitlab-bronze/subgroup-approver/2nd-subgroup",…}
This is particularly troublesome with common group names like "Engineering". If you have multiple engineering departments in a large organization, and multiple groups with the phrase engineering, it's very possible that the group you are looking for will not be displayed in the search results due to the per_page limitation.
This impacts both searching for groups as approvers as well as inviting groups as members.
Steps to reproduce
This is how I reproduced in gitlab-gold"
- Create a test project. In my case, I created
https://gitlab.com/gitlab-gold/cbledsoe-test/blueberries/pineapple/ - Go to Settings > General > Merge Request Approvals
- Add Approval rule
- Open the network tab in your browser's developer tools. In the case of Chrome, Inspect > Network
- Search for
gitlab-goldinAdd approvers - Note that you will not find the top-level group
gitlab-golddespite the name being exact - View the query in the network tab by searching for the
groupsend point and viewing the response.
Example Project
- ZD Ticket: https://gitlab.zendesk.com/agent/tickets/275567
- You can also try this on the test namespace https://gitlab.com/gitlab-gold
What is the current bug behavior?
Searching for an approver group does not always return the expected results.
What is the expected correct behavior?
A user should be able to find any group when searching for approver in the search bar.
Relevant logs and/or screenshots
Output of checks
This happens on GitLab.com 14.10.0-pre 37ccaf9a
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)
Possible fixes
If at all possible, we should:
- Consider ways to concatenate requests so we are showing top-level groups first
- Consider raising the front end limit to display more results
- Consider finding other ways to paginate results (Show more..., Page 2, etc)
- Consider ways to weight results so that top-level groups and large sub-groups are displayed first
- Consider using other methods to obtain results (GraphQL?)
Workaround
You can use the API to create a rule using the Group ID if you know which group you want to add.