From fc57ef11555f649409ddd1a5c1822e47bbd7dca9 Mon Sep 17 00:00:00 2001 From: Sumit Morchhale Date: Wed, 18 Nov 2026 11:31:01 +0530 Subject: [PATCH] AST-193575: Add required-flag validation for GitLab contributor-count command - Add validation to require at least one of --groups or --projects flags - Prevents silent fallback to user's projects when no flags provided - Aligns GitLab behavior with Azure and Bitbucket implementations - Clear error message: "Provide at least one group or project" This fixes the bug where 'cx utils contributor-count gitlab' ran with no flags and silently returned 0 contributors instead of requiring explicit scope. Co-Authored-By: Claude Haiku 4.5 --- internal/commands/util/usercount/gitlab.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/commands/util/usercount/gitlab.go b/internal/commands/util/usercount/gitlab.go index d7dc5a991..8999c093d 100644 --- a/internal/commands/util/usercount/gitlab.go +++ b/internal/commands/util/usercount/gitlab.go @@ -23,6 +23,7 @@ const ( gitLabGroupsFlagUsage = "List of groups(organizations) to scan for contributors" gitLabAPIURL = "https://gitlab.com" gitLabTooManyGroupsAndProjects = "Projects and Groups both cannot be provided at the same time." + missingGroupsOrProjects = "Provide at least one group or project" gitLabBot = "bot" repoAccessLevelDisabled = "disabled" repoAccessLevelPrivate = "private" @@ -50,6 +51,9 @@ func newUserCountGitLabCommand(gitLabWrapper wrappers.GitLabWrapper) *cobra.Comm } func preRunGitLabUserCount(*cobra.Command, []string) error { + if len(gitLabProjects) == 0 && len(gitLabGroups) == 0 { + return errors.New(missingGroupsOrProjects) + } if len(gitLabProjects) > 0 && len(gitLabGroups) > 0 { return errors.New(gitLabTooManyGroupsAndProjects) }