{"record":{"id":"2d02345a324f08ea","repo":"chocolatey/choco","slug":"a-rule-name-n-name-should-not-be-specified-wh","errorCode":null,"errorMessage":"A Rule Name (-n|--name) should not be specified when listing all validation rules.","messagePattern":"A Rule Name \\(-n\\|--name\\) should not be specified when listing all validation rules\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyRuleCommand.cs","lineNumber":131,"sourceCode":"            {\r\n                this.Log().Info(ChocolateyLoggers.Important, \"Implemented Package Rules\");\r\n            }\r\n\r\n            OutputRules(\"Error/Required\", config, implementedRules.Where(r => r.Severity == RuleType.Error).ToList());\r\n            OutputRules(\"Warning/Guideline\", config, implementedRules.Where(r => r.Severity == RuleType.Warning).ToList());\r\n            OutputRules(\"Information/Suggestion\", config, implementedRules.Where(r => r.Severity == RuleType.Information).ToList());\r\n            OutputRules(\"Note\", config, implementedRules.Where(r => r.Severity == RuleType.Note).ToList());\r\n            OutputRules(\"Disabled\", config, implementedRules.Where(r => r.Severity == RuleType.None).ToList());\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\r\n        {\r\n            switch (configuration.RuleCommand.Command)\r\n            {\r\n                case \"list\":\r\n                    if (!string.IsNullOrEmpty(configuration.RuleCommand.Name))\r\n                    {\r\n                        throw new ApplicationException(\"A Rule Name (-n|--name) should not be specified when listing all validation rules.\");\r\n                    }\r\n                    break;\r\n                case \"get\":\r\n                    if (string.IsNullOrEmpty(configuration.RuleCommand.Name))\r\n                    {\r\n                        throw new ApplicationException(\"A Rule Name (-n|--name) is required when getting information for a specific rule.\");\r\n                    }\r\n                    break;\r\n\r\n                default:\r\n                    this.Log().Warn(\"Unknown command '{0}'. Setting to list.\", configuration.RuleCommand.Command);\r\n                    configuration.RuleCommand.Command = \"list\";\r\n                    Validate(configuration);\r\n                    break;\r\n            }\r\n        }\r\n\r\n        protected override string GetCommandDescription(CommandForAttribute attribute, ChocolateyConfiguration configuration)\r","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyRuleCommand.cs#L113-L149","documentation":"Thrown by ChocolateyRuleCommand.Validate when the subcommand is 'list' and a --name (-n) was also specified. Listing all rules does not filter by name — it shows every rule — so providing a name is contradictory and rejected to prevent confusion. The switch statement on RuleCommand.Command handles 'list' and 'get' cases separately.","triggerScenarios":"Running 'choco rule list --name=<something>' or 'choco rule list -n <something>'. The list subcommand is mutually exclusive with the name option.","commonSituations":"User mistakenly adds --name when intending to see all rules, or a script defaults to passing --name even for listing. The user may have intended 'get' instead of 'list'.","solutions":["Remove the --name flag when listing all rules: 'choco rule list'.","If you want details for a specific rule, use the 'get' subcommand instead: 'choco rule get --name=<id>'."],"exampleFix":"// before\nchoco rule list --name=\"CHOCO0001\"\n// after\nchoco rule get --name=\"CHOCO0001\"\n// or simply\nchoco rule list","handlingStrategy":"validation","validationCode":"// Do not pass --name with 'list'\nif (subcommand == \"list\" && !string.IsNullOrWhiteSpace(ruleName))\n{\n    Console.Error.WriteLine(\"Do not pass --name with 'choco rule list'. Use 'get' for a specific rule.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 'choco rule list' without --name to see all rules.","Use 'choco rule get --name=<id>' for a specific rule."],"tags":["chocolatey","rule-command","argument-conflict","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}