{"record":{"id":"0bf7e5ea6f8bd587","repo":"chocolatey/choco","slug":"an-error-has-occurred-this-package-version-alread","errorCode":null,"errorMessage":"An error has occurred. This package version already exists on the repository and cannot be modified.{0}Package versions that are approved, rejected, or exempted cannot be modified.{0}See https://docs.chocolatey.org/en-us/community-repository/moderation/ for more information","messagePattern":"An error has occurred\\. This package version already exists on the repository and cannot be modified\\.(.+?)Package versions that are approved, rejected, or exempted cannot be modified\\.(.+?)See https://docs\\.chocolatey\\.org/en-us/community-repository/moderation/ for more information","errorType":"exception","errorClass":"ApplicationException","httpStatus":null,"severity":"error","filePath":"src/chocolatey/infrastructure.app/nuget/NugetPush.cs","lineNumber":78,"sourceCode":"                    symbolSource: \"\",\r\n                    Convert.ToInt32(timeout.TotalSeconds),\r\n                    disableBuffering,\r\n                    endpoint => config.PushCommand.Key,\r\n                    getSymbolApiKey: null,\r\n                    noServiceEndpoint,\r\n                    skipDuplicate,\r\n                    symbolPackageUpdateResource: null,\r\n                    nugetLogger).GetAwaiter().GetResult();\r\n            }\r\n            catch (Exception ex) when (ex is InvalidOperationException || ex is HttpRequestException)\r\n            {\r\n\r\n                var message = ex.Message;\r\n                if (!string.IsNullOrWhiteSpace(message))\r\n                {\r\n                    if (config.Sources == ApplicationParameters.ChocolateyCommunityFeedPushSource && message.Contains(\"already exists and cannot be modified\"))\r\n                    {\r\n                        throw new ApplicationException(\"An error has occurred. This package version already exists on the repository and cannot be modified.{0}Package versions that are approved, rejected, or exempted cannot be modified.{0}See https://docs.chocolatey.org/en-us/community-repository/moderation/ for more information\".FormatWith(Environment.NewLine), ex);\r\n                    }\r\n\r\n                    if (message.Contains(\"406\") || message.Contains(\"409\"))\r\n                    {\r\n                        // Let this fall through so the actual error message is shown when the exception is re-thrown\r\n                        \"chocolatey\".Log().Error(\"An error has occurred. It's possible the package version already exists on the repository or a nuspec element is invalid. See error below...\");\r\n                    }\r\n                }\r\n\r\n                throw;\r\n            }\r\n\r\n            \"chocolatey\".Log().Info(ChocolateyLoggers.Important, () => \"{0} was pushed successfully to {1}\".FormatWith(nupkgFileName, config.Sources));\r\n        }\r\n\r\n#pragma warning disable IDE0022, IDE1006\r\n        [Obsolete(\"This overload is deprecated and will be removed in v3.\")]\r\n        public static void push_package(ChocolateyConfiguration config, string nupkgFilePath, ILogger nugetLogger, string nupkgFileName, IFileSystem filesystem)\r","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/chocolatey/choco/blob/0d5abdd10cc177a141e69547cad6935b419b6c17/src/chocolatey/infrastructure.app/nuget/NugetPush.cs#L60-L96","documentation":"Thrown by NugetPush when pushing to the Chocolatey community feed (ChocolateyCommunityFeedPushSource) and the underlying NuGet push operation throws InvalidOperationException or HttpRequestException whose message contains 'already exists and cannot be modified'. The community feed does not allow re-uploading or modifying package versions that have entered moderation (approved, rejected, or exempted). This is a feed policy enforcement, not a technical error.","triggerScenarios":"Running 'choco push' for a package version that was already uploaded to the community feed and has been moderated. The exception chain originates from the NuGet PackageUpdateResource.Push call which returns an HTTP 409 Conflict from the server. The catch filter matches on the community feed push source URL and the specific error message fragment.","commonSituations":"Maintainer tries to push a fix to an existing version instead of bumping the version. CI/CD pipeline re-runs and attempts to push the same version. Package was rejected in moderation and maintainer tries to re-push the same version. Version number wasn't incremented before building and pushing.","solutions":["Increment the package version in the .nuspec and push the new version","If the version was rejected in moderation, fix the issues and push a new incremented version","Check the moderation status at https://community.chocolatey.org/packages/<yourpackage> before pushing","For internal/private feeds this error does not apply; ensure --source points to your private feed if that's the intent"],"exampleFix":"// before\n// nuspec has <version>1.0.0</version> which was already pushed and moderated\nchoco push --source=https://push.chocolatey.org/\n\n// after\n// bump version in nuspec to <version>1.0.1</version>\n// rebuild, then:\nchoco push --source=https://push.chocolatey.org/","handlingStrategy":"try-catch","validationCode":"// Check package version before pushing to avoid duplicate\nvar metadata = new ChocolateyPackageMetadata(nupkgPath);\nvar existingPackages = nugetListService.Search($\"id:{metadata.Id}\");\nvar versionExists = existingPackages.Any(p => p.Version == metadata.Version.ToString());\nif (versionExists)\n{\n    Console.Error.WriteLine($\"Version {metadata.Version} already exists. Bump the version.\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    NugetPush.Run(config, nupkgPath, nugetLogger, filesystem);\n}\ncatch (ApplicationException ex) when (ex.Message.Contains(\"already exists\"))\n{\n    logger.Error(\"Package version already pushed and moderated. Increment the version number.\");\n    // Suggest version bump\n}","preventionTips":["Always increment the package version in the .nuspec before building and pushing","In CI/CD, check if the version already exists on the feed before pushing","Use semantic versioning to systematically bump versions","Check moderation status at https://community.chocolatey.org/packages/<id> before re-pushing","For private feeds, use --skip-duplicate if available to avoid hard failures on conflicts"],"tags":["push","nuget","community-feed","version-conflict","moderation"],"backgroundTag":null,"analyzedSha":"0d5abdd10cc177a141e69547cad6935b419b6c17","analyzedAt":"2026-08-13T18:33:03.301Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}