You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feed2catalog produces catalog items with invalid dependency version ranges #3482
feeds should validate packages and avoid displaying invalid data in the feed
Actual
From the client install-package nservicebus.persistence.sql.msbuild -version 1.0.0-beta0006
fails with:
install-package : An error occurred while retrieving package metadata for 'nservicebus.persistence.sql.msbuild.1.0.0-beta0006' from source 'nuget.org'.
'$version$' is not a valid version string.
Microsoft.VisualStudio.Services.Gallery.WebApi
'[15.106.0.preview]' is not a valid version string.
ServiceStack.Extras.Serilog
'0.0.0-~4' is not a valid version string.
BaseLine
Invalid
MassTransit.RavenDbIntegration
'0.0.0-~3' is not a valid version string.
These packages can all still be uploaded to the Gallery.
The Gallery deserializes data from .nuspecs using a NuGet.Packaging class called NuSpecReader. When this class sees an invalid version range, it silently handles it and returns a version range that contains all versions. As a result, the Gallery has no visibility on broken metadata and cannot reject packages with invalid version ranges.
I suggest either
Leave the metadata flow intact and modify the client to install the latest version of a package dependency when it encounters a range it cannot understand.
Modify NuSpecReader to throw an exception when it encounters invalid data and then handle the exceptions on the Gallery side.
We have concluded that we should both modify the client to install the latest/oldest version of a package dependency when it encounters a range it cannot understand AND modify NuSpecReader to throw an exception when it encounters invalid data and then handle the exception on the gallery side.
changed the title [-]Invalid version range in v3 registration blob[/-][+]Gallery accepts packages with illegal package dependency version ranges[/+]on Mar 6, 2017
@joelverhagen The issue is when a customer runs the following command using a nuget.exe the user will get an error and can not install the latest version of the package. We made a mistake on the version dependency for an older version of the package, and there is no way that I know of to fix that on our side. We had a '.' instead of a '-' in [15.106.0.preview]
Installing package 'Microsoft.VisualStudio.Services.Gallery.WebApi' to 'C:'.
GET https://www.myget.org/F/nugetvssprivate/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.visualstudio.services.gallery.webapi/index.json
GET https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/microsoft.visualstudio.services.gallery.webapi/index.json 281ms
NotFound https://www.myget.org/F/nugetvssprivate/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json 574ms
NotFound https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json 2002ms
An error occurred while retrieving package metadata for 'Microsoft.VisualStudio.Services.Gallery.WebApi' from source 'nuget.org'.
'[15.106.0.preview]' is not a valid version string.
NuGet.Protocol.Core.Types.FatalProtocolException: An error occurred while retrieving package metadata for 'Microsoft.VisualStudio.Services.Gallery.WebApi' from source 'nuget.org'. ---> System.ArgumentException: '[15.106.0.preview]' is not a valid version string.
at NuGet.Versioning.VersionRange.Parse(String value, Boolean allowFloating)
at NuGet.Protocol.Utils.CreateVersionRange(String stringToParse)
at NuGet.Protocol.ResolverMetadataClient.ProcessPackageVersion(JObject packageObj, NuGetVersion version)
at NuGet.Protocol.ResolverMetadataClient.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.ResolverMetadataClient.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.DependencyInfoResourceV3.d__5.MoveNext()
--- End of inner exception stack trace ---
at NuGet.Protocol.DependencyInfoResourceV3.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.d__90.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.<>c__DisplayClass89_1.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.d__89.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.d__88.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.InstallCommand.d__40.MoveNext()
changed the title [-]Gallery accepts packages with illegal package dependency version ranges[/-][+]feed2catalog produces catalog items with invalid dependency version ranges[/+]on Oct 30, 2017
All packages on nuget.org with invalid version ranges have been reflowed. nuget.exe install works on all of the three package IDs with invalid dependency version ranges:
Activity
emgarten commentedon Jan 22, 2017
More examples
scottbommarito commentedon Feb 17, 2017
These packages can all still be uploaded to the Gallery.
The Gallery deserializes data from
.nuspecs using aNuGet.Packagingclass calledNuSpecReader. When this class sees an invalid version range, it silently handles it and returns a version range that contains all versions. As a result, the Gallery has no visibility on broken metadata and cannot reject packages with invalid version ranges.I suggest either
NuSpecReaderto throw an exception when it encounters invalid data and then handle the exceptions on the Gallery side.scottbommarito commentedon Feb 21, 2017
We have concluded that we should both modify the client to install the latest/oldest version of a package dependency when it encounters a range it cannot understand AND modify
NuSpecReaderto throw an exception when it encounters invalid data and then handle the exception on the gallery side.[-]Invalid version range in v3 registration blob[/-][+]Gallery accepts packages with illegal package dependency version ranges[/+]joelverhagen commentedon Mar 6, 2017
This work item is: In the gallery, reject new packages with bad dependency version ranges. Just a validation task.
19 remaining items
tedchamb commentedon Oct 19, 2017
@joelverhagen The issue is when a customer runs the following command using a nuget.exe the user will get an error and can not install the latest version of the package. We made a mistake on the version dependency for an older version of the package, and there is no way that I know of to fix that on our side. We had a '.' instead of a '-' in [15.106.0.preview]
nuget.exe install install Microsoft.VisualStudio.Services.Gallery.WebApi -Verbosity Detailed -Pre
NuGet Version: 4.4.0.4475
Feeds used:
E:\tfsomNuGet\Release_RealSigned_20170930.1
https://www.myget.org/F/dotnet-core/api/v3/index.json
https://api.nuget.org/v3/index.json
https://www.myget.org/F/nugetvssprivate/api/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Installing package 'Microsoft.VisualStudio.Services.Gallery.WebApi' to 'C:'.
GET https://www.myget.org/F/nugetvssprivate/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.visualstudio.services.gallery.webapi/index.json
GET https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/microsoft.visualstudio.services.gallery.webapi/index.json 281ms
NotFound https://www.myget.org/F/nugetvssprivate/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json 574ms
NotFound https://dotnet.myget.org/F/dotnet-core/api/v3/registration1/microsoft.visualstudio.services.gallery.webapi/index.json 2002ms
An error occurred while retrieving package metadata for 'Microsoft.VisualStudio.Services.Gallery.WebApi' from source 'nuget.org'.
'[15.106.0.preview]' is not a valid version string.
NuGet.Protocol.Core.Types.FatalProtocolException: An error occurred while retrieving package metadata for 'Microsoft.VisualStudio.Services.Gallery.WebApi' from source 'nuget.org'. ---> System.ArgumentException: '[15.106.0.preview]' is not a valid version string.
at NuGet.Versioning.VersionRange.Parse(String value, Boolean allowFloating)
at NuGet.Protocol.Utils.CreateVersionRange(String stringToParse)
at NuGet.Protocol.ResolverMetadataClient.ProcessPackageVersion(JObject packageObj, NuGetVersion version)
at NuGet.Protocol.ResolverMetadataClient.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.ResolverMetadataClient.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.Protocol.DependencyInfoResourceV3.d__5.MoveNext()
--- End of inner exception stack trace ---
at NuGet.Protocol.DependencyInfoResourceV3.d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.d__90.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.<>c__DisplayClass89_1.<b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.d__89.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.PackageManagement.NuGetPackageManager.d__88.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NuGet.CommandLine.InstallCommand.d__40.MoveNext()
joelverhagen commentedon Oct 25, 2017
After this fix is deployed, the following packages should be reflowed:
[-]Gallery accepts packages with illegal package dependency version ranges[/-][+]feed2catalog produces catalog items with invalid dependency version ranges[/+]joelverhagen commentedon Nov 3, 2017
All packages on nuget.org with invalid version ranges have been reflowed.
nuget.exe installworks on all of the three package IDs with invalid dependency version ranges:Note that nuget.exe treats invalid version ranges as the "any version" range
(, ).@tedchamb, let me know if you run into any other issues.
In feed2catalog, default to empty string if the version range is miss…