Skip to content

Improve GQL query for fetching groups and projects

Mireya Andres requested to merge job-token-search-limitation into master

What does this MR do and why?

Implements #473747 (closed).

Problem

When adding a group or project to the allowlist for CI_JOB_TOKEN, the search is limited to showing up to 4 items in the results.

This means that some groups/projects will not show up if there are more than 4 groups/projects with the same name or path. In some cases, it becomes impossible to add a parent subgroup, even when typing the full path of the parent group.

Proposed Solution

A frontend solution would be to update the GraphQL to use sort: id_asc to prioritize groups that were created first. It is more likely that groups with shorter full paths will show up in the results this way, though this will not be guaranteed.

We can also set searchNamespaces: true for better search results for projects.

Note: A more comprehensive solution would be to apply a sorting mechanism that checks for the closest match, perhaps by prioritizing exact matches first as well as taking into account the depth of the each search result (prioritizing parent groups over nested subgroups, and letting the user refine the search to pull up more nested results). This requires some backend work. This MR is just an improvement that could be made on the frontend.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Search Term Before After
cookie before_cookie after_cookie
dessert before_dessert after_dessert
dessert/dessert before_dessert_dessert after_dessert_dessert
dessert/dessert/cookie before_dessert_dessert_cookie after_dessert_dessert_cookie

How to set up and validate locally

  1. Create more than 4 subgroups, each one nested by the previous. Create one group for each subgroup, then a subgroup for each subgroup. Make sure the subgroups have the same name, and the projects also have the same name. You should have a setup like the following:
    • group/subgroup1/project
    • group/subgroup1/subgroup/project
    • group/subgroup1/subgroup/subgroup/project
    • group/subgroup1/subgroup/subgroup/subgroup/project
    • group/subgroup1/subgroup/subgroup/subgroup/subgroup/project
  2. Go to the CI/CD Settings and expand Job token permissions
  3. Click Add group or project and try to search for the project name, project path, subgroup name, and subgroup path. You should have better search results than before the GQL was updated.
Edited by Mireya Andres

Merge request reports

Loading