{"record":{"id":"1b2ed46a59f6e0a0","repo":"chocolatey/choco","slug":"the-page-size-has-been-specified-to-be-0-n0-pack","errorCode":null,"errorMessage":"The page size has been specified to be {0:N0} packages. The page size cannot be lower than 1 package, and no larger than 100 packages.","messagePattern":"The page size has been specified to be (.+?) packages\\. The page size cannot be lower than 1 package, and no larger than 100 packages\\.","errorType":"validation","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs","lineNumber":190,"sourceCode":"\r\n        public virtual void ParseAdditionalArguments(IList<string> unparsedArguments, ChocolateyConfiguration configuration)\r\n        {\r\n            configuration.Input = string.Join(\" \", unparsedArguments);\r\n        }\r\n\r\n        public virtual void Validate(ChocolateyConfiguration configuration)\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            if (configuration.ListCommand.PageSize < 1 || configuration.ListCommand.PageSize > 100)\r\n            {\r\n                var message = \"The page size has been specified to be {0:N0} packages. The page size cannot be lower than 1 package, and no larger than 100 packages.\".FormatWith(configuration.ListCommand.PageSize);\r\n                throw new ApplicationException(message);\r\n            }\r\n        }\r\n\r\n        public virtual void HelpMessage(ChocolateyConfiguration configuration)\r\n        {\r\n            this.Log().Info(ChocolateyLoggers.Important, \"Search Command\");\r\n            this.Log().Info(@\"\r\nChocolatey will perform a search for a package local or remote.\r\n\");\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, \"Usage\");\r\n            // TODO: use command name in usage and examples, instead of hard\r\n            // coding the names?\r\n            \"chocolatey\".Log().Info(@\"\r\n    choco find <filter> [<options/switches>]\r\n    choco search <filter> [<options/switches>]\r\n\");\r\n\r","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/commands/ChocolateySearchCommand.cs#L172-L208","documentation":"Thrown by ChocolateySearchCommand.Validate when configuration.ListCommand.PageSize is less than 1 or greater than 100. The page size controls how many packages are fetched per page from remote sources. Values outside [1, 100] are rejected. The {0:N0} format specifier renders the number with thousands separators.","triggerScenarios":"Passing '--page-size=0', '--page-size=-1', '--page-size=101', or '--page-size=500'. Any integer value outside the 1–100 inclusive range triggers this during validation.","commonSituations":"User misunderstands page-size as total result count and sets it very high (e.g. 1000). Script bug sets page-size from an unvalidated variable. Negative values from sign errors in arithmetic.","solutions":["Set --page-size to a value between 1 and 100 inclusive: 'choco search --page-size=30'.","To retrieve more total results, combine --page-size with --page (pagination), not a single huge page size.","Omit --page-size entirely to use the default page size."],"exampleFix":"// before\nchoco search --page-size=500\n// after\nchoco search --page-size=100 --page=1\nchoco search --page-size=100 --page=2","handlingStrategy":"validation","validationCode":"// Validate page size range before calling search\nif (pageSize < 1 || pageSize > 100)\n{\n    Console.Error.WriteLine($\"Page size {pageSize} is out of range [1, 100].\");\n}","typeGuard":"static bool IsValidPageSize(int size) => size >= 1 && size <= 100;","tryCatchPattern":null,"preventionTips":["Keep --page-size between 1 and 100 inclusive.","Use --page for pagination instead of inflating page-size."],"tags":["chocolatey","search-command","out-of-range","pagination"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}