{"record":{"id":"7610810606f60cf2","repo":"chocolatey/choco","slug":"the-0-source-does-not-support-upgrading-packag","errorCode":null,"errorMessage":"The '{0}' source does not support upgrading packages","messagePattern":"The '(.+?)' source does not support upgrading packages","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs","lineNumber":1170,"sourceCode":"                GetInitialEnvironment(config, allowLogging: true);\r\n\r\n                ConcurrentDictionary<string, PackageResult> results;\r\n\r\n                if (config.SourceType.IsEqualTo(SourceTypes.Normal))\r\n                {\r\n                    var action = new Action<PackageResult, ChocolateyConfiguration>((packageResult, configuration) => HandlePackageResult(packageResult, configuration, CommandNameType.Upgrade));\r\n                    var beforeUpgradeAction = new Action<PackageResult, ChocolateyConfiguration>((packageResult, configuration) => BeforeModifyAction(packageResult, configuration));\r\n\r\n                    results = _nugetService.Upgrade(config, action, beforeUpgradeAction);\r\n                }\r\n                else\r\n                {\r\n                    results = PerformSourceRunnerFunction<IUpgradeSourceRunner, ConcurrentDictionary<string, PackageResult>>(config, runner => runner.Upgrade(config, null));\r\n                }\r\n\r\n                if (results is null)\r\n                {\r\n                    throw new NotSupportedException(\"The '{0}' source does not support upgrading packages\".FormatWith(config.SourceType));\r\n                }\r\n\r\n                foreach (var result in results)\r\n                {\r\n                    packageUpgrades.GetOrAdd(result.Key, result.Value);\r\n                }\r\n            }\r\n            finally\r\n            {\r\n                var actionSummaryResult = ReportActionSummary(packageUpgrades, \"upgraded\");\r\n                if (actionSummaryResult.Failures != 0 && Environment.ExitCode == 0)\r\n                {\r\n                    Environment.ExitCode = 1;\r\n                }\r\n\r\n                if (config.Features.UseEnhancedExitCodes && (actionSummaryResult.Successes + actionSummaryResult.Failures == 0) && Environment.ExitCode == 0)\r\n                {\r\n                    Environment.ExitCode = 2;\r","sourceCodeStart":1152,"sourceCodeEnd":1188,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs#L1152-L1188","documentation":"Thrown as a NotSupportedException when an upgrade operation against a non-normal source type returns null results. PerformSourceRunnerFunction<IUpgradeSourceRunner> is called for alternative sources; if no runner implementing IUpgradeSourceRunner is registered, it returns default (null) and this exception fires.","triggerScenarios":"Calling Upgrade with config.SourceType set to a non-normal value when no alternative source runner implementing IUpgradeSourceRunner is registered for that source type. The null-check on results after the runner function completes triggers the throw.","commonSituations":"Running 'choco upgrade --source-type python' where the Python source runner does not implement IUpgradeSourceRunner. Many alternative source runners only support install, not upgrade. Also occurs with typo'd or unregistered source types.","solutions":["Check whether the alternative source runner for your source type implements IUpgradeSourceRunner — some only support install.","For normal feed upgrades, ensure config.SourceType is 'normal' (or omitted).","For custom runners, add IUpgradeSourceRunner to the runner class and implement the Upgrade method.","If the source only supports install, uninstall and reinstall instead of upgrading."],"exampleFix":"// before: runner supports install but not upgrade\npublic class MyRunner : IAlternativeSourceRunner, IInstallSourceRunner { }\n\n// after: add upgrade support\npublic class MyRunner : IAlternativeSourceRunner, IInstallSourceRunner, IUpgradeSourceRunner\n{\n    public ConcurrentDictionary<string, PackageResult> Upgrade(\n        ChocolateyConfiguration config,\n        Action<PackageResult, ChocolateyConfiguration> continueAction,\n        Action<PackageResult, ChocolateyConfiguration> beforeUpgradeAction)\n    {\n        return new ConcurrentDictionary<string, PackageResult>();\n    }\n}","handlingStrategy":"validation","validationCode":"// Verify a runner implementing IUpgradeSourceRunner exists for the source type\nif (!config.SourceType.IsEqualTo(SourceTypes.Normal))\n{\n    var runners = _containerResolver.ResolveAll<IUpgradeSourceRunner>();\n    if (!runners.Any(r => r.SourceType.IsEqualTo(config.SourceType)))\n    {\n        throw new InvalidOperationException($\"No upgrade runner registered for source type '{config.SourceType}'. Not all alternative sources support upgrade.\");\n    }\n}","typeGuard":"public static bool SourceTypeSupportsUpgrade(string sourceType, IEnumerable<IAlternativeSourceRunner> registeredRunners)\n{\n    if (sourceType.IsEqualTo(SourceTypes.Normal)) return true;\n    return registeredRunners.OfType<IUpgradeSourceRunner>().Any(r => r.SourceType.IsEqualTo(sourceType));\n}","tryCatchPattern":"try\n{\n    _packageService.Upgrade(config);\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"does not support upgrading\"))\n{\n    logger.Error($\"Source type '{config.SourceType}' does not support upgrade. Try uninstall + install instead.\");\n}","preventionTips":["Check whether the alternative source runner implements IUpgradeSourceRunner before attempting upgrades.","Not all alternative source types support upgrade — some only support install.","For normal feeds, ensure SourceType is 'normal'.","If upgrade is unsupported, use uninstall followed by install as a workaround."],"tags":["source-runner","alternative-source","upgrade","notsupported","chocolatey"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}