{"record":{"id":"ef2d39393573e568","repo":"chocolatey/choco","slug":"no-order-by-clause-was-provided-specify-one-o","errorCode":null,"errorMessage":"No '--order-by' clause was provided. Specify one of the supported clauses:\n '{0}'.","messagePattern":"No '--order-by' clause was provided\\. Specify one of the supported clauses:\n '(.+?)'\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs","lineNumber":118,"sourceCode":"                     \"ByIdOnly - Only return packages where the id contains the search filter.\",\r\n                     option => configuration.ListCommand.ByIdOnly = option != null)\r\n                 .Add(\"by-tag-only|by-tags-only\",\r\n                     \"ByTagOnly - Only return packages where the search filter matches on the tags.\",\r\n                     option => configuration.ListCommand.ByTagOnly = option != null)\r\n                 .Add(\"id-starts-with\",\r\n                     \"IdStartsWith - Only return packages where the id starts with the search filter.\",\r\n                     option => configuration.ListCommand.IdStartsWith = option != null)\r\n                 .Add(\"order-by=\",\r\n                     \"OrderBy - Sort package results by Id (default), {0}. Available in 2.5.0+.\".FormatWith(string.Join(\", \", Enum.GetNames(typeof(PackageOrder)).Where(n => !n.IsEqualTo(\"Id\")))),\r\n                     option =>\r\n                     {\r\n                        var validOptions = Enum.GetNames(typeof(PackageOrder));\r\n                         var formattedOptions = string.Join(\"', '\", validOptions);\r\n                         var unquotedOption = option.UnquoteSafe();\r\n\r\n                         if (string.IsNullOrWhiteSpace(unquotedOption))\r\n                         {\r\n                             throw new ApplicationException(\r\n                                @\"No '--order-by' clause was provided. Specify one of the supported clauses:\r\n '{0}'.\".FormatWith(formattedOptions));\r\n                         }\r\n\r\n                         if (!Enum.TryParse(unquotedOption, ignoreCase: true, out PackageOrder orderBy))\r\n                         {\r\n                            throw new ApplicationException(\r\n                                @\"The '--order-by' clause '{0}' is not recognized. Use one of the supported clauses:\r\n '{1}'.\".FormatWith(unquotedOption, formattedOptions));\r\n                         }\r\n\r\n                         configuration.ListCommand.OrderBy = orderBy;\r\n                 })\r\n                 .Add(\"order-by-popularity\",\r\n                     \"(Deprecated) OrderByPopularity - Sort package results by popularity. Use '--order-by='Popularity'' instead.\",\r\n                     option =>\r\n                     {\r\n                         if (option != null)\r","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs#L100-L136","documentation":"Thrown during argument parsing for the --order-by option on the search/list command when the option value is present but empty or whitespace after unquoting. The option handler builds a list of valid PackageOrder enum names and includes them in the message. This is a parse-time error, not a validate-time error — it fires inside the lambda registered with the --order-by option.","triggerScenarios":"Running 'choco search --order-by=' (empty value) or 'choco search --order-by=\"\"' (quoted empty string). The UnquoteSafe() call produces an empty string, which fails the IsNullOrWhiteSpace check.","commonSituations":"Script or CI pipeline sets --order-by from a variable that is unexpectedly empty. User accidentally types the flag with no value. Available since Chocolatey 2.5.0+.","solutions":["Provide a valid sort clause from the PackageOrder enum: 'choco search --order-by=Popularity'.","If the sort value comes from a variable, ensure it is non-empty before passing, or omit --order-by entirely to use the default (Id).","Check valid options via the error message itself, which lists them."],"exampleFix":"// before\nchoco search --order-by=\n// after\nchoco search --order-by=Popularity\n// or omit entirely for default Id ordering\nchoco search","handlingStrategy":"validation","validationCode":"// Validate order-by is non-empty before calling search\nif (!string.IsNullOrWhiteSpace(orderBy) && orderBy.UnquoteSafe().Trim() == \"\")\n{\n    Console.Error.WriteLine(\"--order-by value is empty. Valid options: Id, Popularity, ...\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit --order-by entirely to use the default (Id) instead of passing an empty value.","Ensure script variables backing --order-by are non-empty."],"tags":["chocolatey","search-command","argument-validation","order-by"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}