{"record":{"id":"73ca215a45e66ee2","repo":"chocolatey/choco","slug":"the-implementation-of-0-does-not-support-listi-73ca21","errorCode":null,"errorMessage":"The implementation of '{0}' does not support listing.","messagePattern":"The implementation of '(.+?)' does not support listing\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/runners/GenericRunner.cs","lineNumber":310,"sourceCode":"                {\r\n                    task.Shutdown();\r\n                }\r\n\r\n                RemoveNuGetCache(container, config);\r\n            }\r\n        }\r\n\r\n        public int Count(ChocolateyConfiguration config, Container container, bool isConsole, Action<ICommand> parseArgs)\r\n        {\r\n            FailOnMissingOrInvalidLicenseIfFeatureSet(config);\r\n            HttpsSecurity.Reset();\r\n\r\n            var command = FindCommand(config, container, isConsole, parseArgs) as IListCommand;\r\n            if (command == null)\r\n            {\r\n                if (!string.IsNullOrWhiteSpace(config.CommandName))\r\n                {\r\n                    throw new Exception(\"The implementation of '{0}' does not support listing.\".FormatWith(config.CommandName));\r\n                }\r\n                return 0;\r\n            }\r\n            else\r\n            {\r\n                this.Log().Debug(\"_ {0}:{1} - Normal Count Mode _\".FormatWith(ApplicationParameters.Name, command.GetType().Name));\r\n                return command.Count(config);\r\n            }\r\n        }\r\n\r\n        public void WarnIfAdminAndNeedsElevation(ChocolateyConfiguration config)\r\n        {\r\n            if (config.HelpRequested)\r\n            {\r\n                return;\r\n            }\r\n\r\n            // skip when commands will set or for background mode\r","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/runners/GenericRunner.cs#L292-L328","documentation":"Thrown by GenericRunner.Count when the resolved command does not implement IListCommand (the non-generic interface). The Count method requires the command to support listing operations because counting is conceptually a listing capability. If the command exists but cannot be cast to IListCommand, it has no count functionality and the error is thrown.","triggerScenarios":"Running 'choco <command> --count' or an internal API call to GenericRunner.Count where the command is resolved but doesn't implement IListCommand. The command supports installation or other operations but not listing/counting. An alternative source runner type is set but doesn't have list capability.","commonSituations":"User or script invokes a count operation on a command that doesn't support it (e.g. 'choco push --count'). Internal code path incorrectly routes a count request to a non-listing command. Alternative source type is configured but the runner doesn't support search/count.","solutions":["Use a command that supports listing/counting (e.g. 'choco search' or 'choco list')","Verify the command name is correct for the intended count operation","Ensure the source type supports listing if using alternative sources","Check that the command's runner implements IListCommand"],"exampleFix":"// before\nchoco push --count\n// throws: The implementation of 'push' does not support listing.\n\n// after\nchoco search mypackage --count\n// or\nchoco list --count","handlingStrategy":"type-guard","validationCode":"// Check command capability before calling Count\nvar command = FindCommand(config, container, isConsole, parseArgs);\nif (command is IListCommand listCommand)\n{\n    return listCommand.Count(config);\n}\nelse\n{\n    logger.Warn($\"Command '{config.CommandName}' does not support IListCommand for counting.\");\n    return 0;\n}","typeGuard":"public static bool SupportsCount(ICommand command)\n{\n    return command is IListCommand;\n}","tryCatchPattern":"try\n{\n    var count = runner.Count(config, container, isConsole, parseArgs);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"does not support listing\"))\n{\n    logger.Error($\"Command '{config.CommandName}' does not support counting. Use 'choco list --count'.\");\n    return 0;\n}","preventionTips":["Use list/search commands for count operations, not install/push commands","Verify the command implements IListCommand before calling Count","Understand that counting requires listing capability","For alternative sources, verify the runner supports IListCommand"],"tags":["command-resolution","interface-mismatch","counting","listing","internal-api"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}