Optimize group label validation by searching for requested labels instead of paging through the full group tree
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start with validateSubscriptionLabels in server/command.go, then read GetGroupLabels in server/gitlab/api.go, where the paging loop over resp.NextPage lives. Check whether ListGroupLabelsOptions in the GitLab client accepts a Search field. Done when each requested label is checked with a search query, an exact match on Name is still required, and unknown labels are still rejected.
Written by the indexing model from the issue text.
Description
Summary
When adding a group subscription with label filters (e.g., /gitlab subscriptions add group issues,label:"bug"), validateSubscriptionLabels currently calls GetGroupLabels, which pages through every label across the entire group hierarchy (including descendant groups and projects). In large GitLab organizations with hundreds or thousands of labels, this generates unnecessary API requests and causes high latency during command execution.
Thanks to @nang2049 for the suggestion in https://github.com/mattermost/mattermost-plugin-gitlab/pull/726#discussion_r4548460348.
Current Behavior
In server/gitlab/api.go:
opts := &internGitlab.ListGroupLabelsOptions{
ListOptions: internGitlab.ListOptions{
Page: 1,
PerPage: 100,
},
OnlyGroupLabels: &onlyGroupLabels,
IncludeDescendantGrouops: &includeDescendants,
}
GetGroupLabels paginates through all labels in the group hierarchy (resp.NextPage != 0). If a group has many projects and sub-groups, validating a single label can issue numerous paginated HTTP requests to GitLab.
Proposed Solution
GitLab's Group Labels API (ListGroupLabelsOptions) supports a Search parameter. Rather than fetching and paging through the entire group label catalog:
- Query GitLab's group labels endpoint with
Search: &labelfor each label requested in the subscriptionfeaturesstring. - Validate that at least one returned result matches the exact label name (exact match against
l.Name). - This restricts the API interaction to 1–2 requests per subscription command regardless of the total number of labels in the group tree.
Code References & Context
- PR discussion: https://github.com/mattermost/mattermost-plugin-gitlab/pull/726#discussion_r4548460348
- Calling site:
server/command.goinvalidateSubscriptionLabels - API client method:
server/gitlab/api.goinGetGroupLabels
- Dominant language
- JavaScript
- Stars
- 158
- Forks
- 97
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 21
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mattermost/mattermost-plugin-gitlab
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
mattermost/mattermost-plugin-gitlab#738 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
mattermost/mattermost-plugin-gitlab#737 ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 1-2 days Newbie friendliness 53/100
mattermost/mattermost-plugin-gitlab#736 ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
mattermost/mattermost-plugin-gitlab#668 · 1 comment · 2 reactions ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
mattermost/mattermost-plugin-gitlab#616 ·
Maintainers usually reply within 2 days
All issues in mattermost/mattermost-plugin-gitlab
Similar issues
-
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
mayswind/AriaNg-Native#155 ·
-
bug(admin/users): server error returns bare alert HTML causing black-shape visual artifactPossibly taken @lane711 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
SonicJs-Org/sonicjs#1211 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
ci Could Have good first issue
Difficulty 1/5 Under an hour Newbie friendliness 87/100
hannahro15/Musical-Match-Saga#253 ·
Maintainers usually reply within 1 day