Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NRE When Package Metadata CatalogPage Leaf returns 404 #13377

Open
mukunku opened this issue Apr 5, 2024 · 0 comments
Open

NRE When Package Metadata CatalogPage Leaf returns 404 #13377

mukunku opened this issue Apr 5, 2024 · 0 comments
Labels
Area:HttpCommunication Area:Protocol Client/Server protocol /code around it Category:Quality Week Issues that should be considered for quality week Functionality:SDK The NuGet client packages published to nuget.org Priority:2 Issues for the current backlog. Type:Bug

Comments

@mukunku
Copy link

mukunku commented Apr 5, 2024

NuGet Product Used

dotnet.exe, NuGet.exe, NuGet SDK

Product Version

dotnet sdk 8 and almost all versions of NuGet

Worked before?

Issue was introduced in #3462

Impact

It's more difficult to complete my work

Repro Steps & Context

You need to simulate a catalog page list where at least one of the range url 404's.

Here is the JSON my NuGet repo returns:

{
    "@id": "https://my.nuget.repo/v3/registration3-gz-semver2/my.package/index.json",
    "@type": [
        "catalog:CatalogRoot",
        "PackageRegistration",
        "catalog:Permalink"
    ],
    "count": 2,
    "items": [
        {
            "@id": "https://my.nuget.repo/v3/registration3-gz-semver2/my.package/page/7.4.3388/2018.4.0-enh-workersinclien13.json",
            "@type": "catalog:CatalogPage",
            "count": 128,
            "lower": "7.4.3388",
            "upper": "2018.4.0-enh-workersinclien13"
        },
        {
            "@id": "https://my.nuget.repo/v3/registration3-gz-semver2/my.package/page/7.4.3150/7.4.3387.json",
            "@type": "catalog:CatalogPage",
            "count": 128,
            "lower": "7.4.3150",
            "upper": "7.4.3387"
        }
    ]
}

The first page url returns a valid list of versions in that range ✔️ However the second one 404's and the leaf page ends up being null in the code here: https://github.com/NuGet/NuGet.Client/blob/7ad6fcc9c56c960975c37b2416c7eae1d53ba3fd/src/NuGet.Core/NuGet.Protocol/Resources/PackageMetadataResourceV3.cs#L122-L124

And because the if check is checking the wrong variable I get a NRE.

Verbose Logs

The issue happens when running `dotnet tool restore` with the following `dotnet-tools.json`

{
  "version": 1,
  "isRoot": true,
  "tools": {
    "my.package": {
      "version": "9.1.7",
      "commands": [
        "dotnet-tool"
      ]
    }
  }
}


[NuGet Manager] [Info]   GET https://my.nuget.repo/v3/registration3-gz-semver2/my.package/index.json
[NuGet Manager] [Info]   OK https://my.nuget.repo/v3/registration3-gz-semver2/my.package/index.json 237ms
[NuGet Manager] [Info]   GET https://my.nuget.repo/v3/registration3-gz-semver2/my.package/page/7.4.3388/2018.4.0-enh-workersinclien13.json
[NuGet Manager] [Info]   OK https://my.nuget.repo/v3/registration3-gz-semver2/my.package/page/7.4.3388/2018.4.0-enh-workersinclien13.json 108ms
[NuGet Manager] [Info]   GET https://my.nuget.repo/v3/registration3-gz-semver2/my.package/page/7.4.3150/7.4.3387.json
[NuGet Manager] [Info]   NotFound https://my.nuget.repo/v3/registration3-gz-semver2/my.package/page/7.4.3150/7.4.3387.json 131ms
Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at NuGet.Protocol.PackageMetadataResourceV3.ProcessRegistrationPage(RegistrationPage registrationPage, List`1 results, VersionRange range, Boolean includePrerelease, Boolean includeUnlisted, MetadataReferenceCache metadataCache)
   at NuGet.Protocol.PackageMetadataResourceV3.GetMetadataAsync(String packageId, Boolean includePrerelease, Boolean includeUnlisted, VersionRange range, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token)
   at NuGet.Protocol.PackageMetadataResourceV3.GetMetadataAsync(String packageId, Boolean includePrerelease, Boolean includeUnlisted, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetPackageMetadataAsync(PackageSource source, String packageIdentifier, Boolean includePrerelease, Boolean includeUnlisted, CancellationToken cancellationToken)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetPackageMetadataAsync(String packageIdentifier, NuGetVersion packageVersion, IEnumerable`1 sources, CancellationToken cancellationToken, Boolean includeUnlisted)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetPackageSourceAndVersion(PackageId packageId, NuGetVersion packageVersion, PackageSourceLocation packageSourceLocation, Boolean includePreview, Boolean includeUnlisted, PackageSourceMapping packageSourceMapping)
   at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.DownloadPackageAsync(PackageId packageId, NuGetVersion packageVersion, PackageSourceLocation packageSourceLocation, Boolean includePreview, Boolean includeUnlisted, Nullable`1 downloadFolder, PackageSourceMapping packageSourceMapping)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.DownloadAndExtractPackage(PackageLocation packageLocation, PackageId packageId, INuGetPackageDownloader nugetPackageDownloader, String packagesRootPath, IToolPackageStore toolPackageStore, NuGetVersion packageVersion, PackageSourceLocation packageSourceLoca
tion, Boolean includeUnlisted)
   at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.<InstallPackage>b__0()
   at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback)
   at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.InstallPackages(ToolManifestPackage package, Nullable`1 configFile)
   at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.<>c__DisplayClass10_0.<Execute>b__0(ToolManifestPackage package)
   at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.Execute()
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)
@nkolev92 nkolev92 added Area:HttpCommunication Area:Protocol Client/Server protocol /code around it Functionality:SDK The NuGet client packages published to nuget.org Priority:2 Issues for the current backlog. Category:Quality Week Issues that should be considered for quality week and removed Functionality:Restore labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:HttpCommunication Area:Protocol Client/Server protocol /code around it Category:Quality Week Issues that should be considered for quality week Functionality:SDK The NuGet client packages published to nuget.org Priority:2 Issues for the current backlog. Type:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants