{"record":{"id":"124dcefc910fbbbb","repo":"chocolatey/choco","slug":"a-rule-name-n-name-is-required-when-getting-i","errorCode":null,"errorMessage":"A Rule Name (-n|--name) is required when getting information for a specific rule.","messagePattern":"A Rule Name \\(-n\\|--name\\) is required when getting information for a specific rule\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyRuleCommand.cs","lineNumber":137,"sourceCode":"            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\n        {\r\n            return @\"Retrieve information about what rule validations are implemented by Chocolatey CLI.\";\r\n        }\r\n\r\n        protected override IEnumerable<string> GetCommandExamples(CommandForAttribute[] attributes, ChocolateyConfiguration configuration)\r\n        {\r","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyRuleCommand.cs#L119-L155","documentation":"Thrown by ChocolateyRuleCommand.Validate when the subcommand is 'get' and no --name (-n) was provided. The get operation requires a specific rule to look up, so a name is mandatory. Without it, the command has no target rule to display.","triggerScenarios":"Running 'choco rule get' with no --name argument. The switch case 'get' checks if configuration.RuleCommand.Name is null or empty and throws.","commonSituations":"User runs 'choco rule get' expecting a full listing (that is what 'list' does) without specifying which rule to get. Or the --name flag was omitted by mistake in a script.","solutions":["Add the required --name flag: 'choco rule get --name=<rule-id>'.","Run 'choco rule list' first to discover available rule ids.","If you want to list all rules, use 'choco rule list' instead."],"exampleFix":"// before\nchoco rule get\n// after\nchoco rule get --name=\"CHOCO0001\"","handlingStrategy":"validation","validationCode":"// Ensure --name is provided for 'get'\nif (subcommand == \"get\" && string.IsNullOrWhiteSpace(ruleName))\n{\n    Console.Error.WriteLine(\"'choco rule get' requires --name=<rule-id>. Run 'choco rule list' to see options.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide --name with 'choco rule get'.","Use 'choco rule list' when you want all rules."],"tags":["chocolatey","rule-command","missing-argument","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}