{"record":{"id":"79854f7d62106a97","repo":"chocolatey/choco","slug":"no-rule-with-the-name-0-could-be-found","errorCode":null,"errorMessage":"No rule with the name {0} could be found.","messagePattern":"No rule with the name (.+?) could be found\\.","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateyRuleCommand.cs","lineNumber":91,"sourceCode":"                configuration.RuleCommand.Name = unparsedArguments[1];\r\n            }\r\n        }\r\n\r\n        public virtual void Run(ChocolateyConfiguration config)\r\n        {\r\n            IEnumerable<ImmutableRule> implementedRules = _ruleService.GetAllAvailableRules().OrderBy(r => r.Id);\r\n\r\n            if (!string.IsNullOrEmpty(config.RuleCommand.Name))\r\n            {\r\n                var foundRule = implementedRules.FirstOrDefault(i => i.Id.IsEqualTo(config.RuleCommand.Name));\r\n\r\n                // Since the return value is a structure, it will never be null.\r\n                // As such we check that the identifier is not empty.\r\n                if (config.RegularOutput)\r\n                {\r\n                    if (string.IsNullOrEmpty(foundRule.Id))\r\n                    {\r\n                        throw new ApplicationException(\"No rule with the name {0} could be found.\".FormatWith(config.RuleCommand.Name));\r\n                    }\r\n\r\n                    // Not using multiline logging here, as it causes issues\r\n                    // with unit tests.\r\n                    this.Log().Info(\"Name: {0} | Severity: {1}\", foundRule.Id, foundRule.Severity);\r\n                    this.Log().Info(\"Summary: {0}\", foundRule.Summary);\r\n                    this.Log().Info(\"Help URL: {0}\", foundRule.HelpUrl);\r\n\r\n                    return;\r\n                }\r\n                else if (!string.IsNullOrEmpty(foundRule.Id))\r\n                {\r\n                    implementedRules = new[] { foundRule };\r\n                }\r\n                else\r\n                {\r\n                    return;\r\n                }\r","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateyRuleCommand.cs#L73-L109","documentation":"Thrown by ChocolateyRuleCommand when the command is invoked in 'get' mode (RegularOutput is true) and the specified --name does not match any rule Id in the set of all available rules returned by _ruleService.GetAllAvailableRules(). The lookup uses a case-insensitive equality check (IsEqualTo) on the rule Id. Because ImmutableRule is a struct, the FirstOrDefault never returns null — the code instead checks for an empty Id string.","triggerScenarios":"Running 'choco rule get --name=<ruleId>' where <ruleId> does not match any implemented rule's Id. The match is exact (case-insensitive). Typographical errors or referencing a rule that does not exist in the current Chocolatey version triggers this.","commonSituations":"User copies a rule name from documentation for a different Chocolatey version, or mistypes the rule id. Rule names may change between versions as new rules are added or renamed.","solutions":["List all available rules first to find the exact id: 'choco rule list'.","Copy the exact rule id from the list output and retry: 'choco rule get --name=<exact-id>'.","Check rule name case and spelling carefully."],"exampleFix":"// before\nchoco rule get --name=\"choco-001\"\n// after\nchoco rule list\n# find the correct id, e.g. \"CHOCO0001\"\nchoco rule get --name=\"CHOCO0001\"","handlingStrategy":"validation","validationCode":"// Verify rule exists before 'get'\nvar rules = RunChoco(\"rule list\");\nvar ruleNames = ParseRuleNames(rules);\nif (!ruleNames.Contains(ruleName, StringComparer.OrdinalIgnoreCase))\n{\n    Console.Error.WriteLine($\"Rule '{ruleName}' does not exist. Available: {string.Join(\", \", ruleNames)}\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    RunChoco($\"rule get --name={ruleName}\");\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"No rule with the name\"))\n{\n    logger.Warn($\"Rule '{ruleName}' not found. Run 'choco rule list' for valid ids.\");\n}","preventionTips":["Run 'choco rule list' to discover valid rule ids before using 'get'.","Copy the exact id from the list output."],"tags":["chocolatey","rule-command","not-found","validation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}