{"record":{"id":"d0c3dbf86e5de405","repo":"chocolatey/choco","slug":"when-specifying-the-subcommand-0-you-must-als-d0c3db","errorCode":null,"errorMessage":"When specifying the subcommand '{0}', you must also specify --name.","messagePattern":"When specifying the subcommand '(.+?)', you must also specify --name\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs","lineNumber":110,"sourceCode":"            Enum.TryParse(unparsedCommand, true, out command);\r\n            if (command == SourceCommandType.Unknown)\r\n            {\r\n                if (!string.IsNullOrWhiteSpace(unparsedCommand))\r\n                {\r\n                    this.Log().Warn(\"Unknown command {0}. Setting to list.\".FormatWith(unparsedCommand));\r\n                }\r\n\r\n                command = SourceCommandType.List;\r\n            }\r\n\r\n            configuration.SourceCommand.Command = command;\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            if (configuration.SourceCommand.Command != SourceCommandType.List && string.IsNullOrWhiteSpace(configuration.SourceCommand.Name))\r\n            {\r\n                throw new ApplicationException(\"When specifying the subcommand '{0}', you must also specify --name.\".FormatWith(configuration.SourceCommand.Command.ToStringSafe().ToLower()));\r\n            }\r\n\r\n            if (configuration.SourceCommand.Command == SourceCommandType.Add && string.IsNullOrWhiteSpace(configuration.Sources))\r\n            {\r\n                throw new ApplicationException(\"When specifying the subcommand 'add', you must also specify --source.\");\r\n            }\r\n\r\n            if (!string.IsNullOrWhiteSpace(configuration.SourceCommand.Username) && string.IsNullOrWhiteSpace(configuration.SourceCommand.Password))\r\n            {\r\n                this.Log().Debug(ChocolateyLoggers.LogFileOnly, \"Username '{0}' provided. Asking for password.\".FormatWith(configuration.SourceCommand.Username));\r\n                System.Console.Write(\"User name '{0}' provided. Password: \".FormatWith(configuration.SourceCommand.Username));\r\n                configuration.SourceCommand.Password = InteractivePrompt.GetPassword(configuration.PromptForConfirmation);\r\n            }\r\n        }\r\n\r\n        public virtual void HelpMessage(ChocolateyConfiguration configuration)\r\n        {\r\n            this.Log().Info(ChocolateyLoggers.Important, \"Source Command\");\r","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateySourceCommand.cs#L92-L128","documentation":"Thrown by ChocolateySourceCommand.Validate when the subcommand is not 'list' and no --name was provided. All non-list source operations (add, remove, disable, enable) require a --name to identify which source to act upon. Without a name the operation has no target.","triggerScenarios":"Running 'choco source add', 'choco source remove', 'choco source disable', or 'choco source enable' without --name=<source-name>. The condition: SourceCommand.Command != List AND SourceCommand.Name is empty.","commonSituations":"User runs 'choco source disable' without specifying which source. User expects an interactive prompt but the command requires explicit --name. Script omits --name due to a variable expansion issue.","solutions":["Add the --name flag with the source name: 'choco source disable --name=myfeed'.","Run 'choco source list' first to see configured source names.","For add operations, also remember --source (the URL) is required."],"exampleFix":"// before\nchoco source disable\n// after\nchoco source disable --name=\"myfeed\"","handlingStrategy":"validation","validationCode":"// For non-list source ops, ensure --name\nif (sourceSubcommand != \"list\" && string.IsNullOrWhiteSpace(sourceName))\n{\n    Console.Error.WriteLine($\"choco source {sourceSubcommand} requires --name=<source>.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include --name for add/remove/disable/enable source operations.","Run 'choco source list' to see configured source names."],"tags":["chocolatey","source-command","missing-argument","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}