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

Deprecation information omitted from search result #8719

Closed
Jericho opened this issue Oct 17, 2019 · 4 comments
Closed

Deprecation information omitted from search result #8719

Jericho opened this issue Oct 17, 2019 · 4 comments
Labels
Functionality:SDK The NuGet client packages published to nuget.org Resolution:BlockedByExternal Progress on this task is blocked by an external issue. When that issue is completed this can proceed Type:Feature
Milestone

Comments

@Jericho
Copy link

Jericho commented Oct 17, 2019

I am using the Nuget.Protocol 5.3.0+b75150f2f4127a77a166c9552845e86fb24a3282 nuget package in my C# console app to fetch information about various packages that interest me. I am noticing that I can get deprecation information about a given package if the metadata was obtained by invoking PackageMetadataResource.GetMetadataAsync. However, the deprecation information for the same pakage is null if the metadata was obtained by invoking PackageSearchResource.SearchAsync.

Here is C# code to reproduce the problem:

var packageId = "Cake.Tfs";

// Prepare the nuget client
var providers = new List<Lazy<INuGetResourceProvider>>();
providers.AddRange(NuGet.Protocol.Core.Types.Repository.Provider.GetCoreV3());  // Add v3 API support
var packageSource = new PackageSource("https://api.nuget.org/v3/index.json");
var nugetRepository = new SourceRepository(packageSource, providers);

// Fetch the package metadata using the 'GetMetadataAsync' method
var nugetPackageMetadataClient = await nugetRepository.GetResourceAsync<PackageMetadataResource>().ConfigureAwait(false);
var getMetadataResult = await nugetPackageMetadataClient.GetMetadataAsync(packageId, true, false, new SourceCacheContext(), NullLogger.Instance, CancellationToken.None).ConfigureAwait(false);
var packageMetadata = getMetadataResult.OrderByDescending(p => p.Published).First();
var packageMetadataDeprecationInfo = await packageMetadata.GetDeprecationMetadataAsync().ConfigureAwait(false);

// Search for the package
var filters = new SearchFilter(true) { IncludeDelisted = false };
var nugetSearchClient = nugetRepository.GetResource<PackageSearchResource>();
var searchResult = await nugetSearchClient.SearchAsync(packageId, filters, 0, 1000, NullLogger.Instance, CancellationToken.None).ConfigureAwait(false);
var searchMetadata = searchResult.Single(r => r.Identity.Id == packageId);
var searchMetadataDeprecationInfo = await searchMetadata.GetDeprecationMetadataAsync().ConfigureAwait(false);

// Display what we found
Console.WriteLine($"Package {packageId} deprecated when using the 'GetMetadataAsync' method: {packageMetadataDeprecationInfo != null}");
Console.WriteLine($"Package {packageId} deprecated when using the 'SearchAsync' method: {searchMetadataDeprecationInfo != null}");

The following is output to the console:

Package Cake.Tfs deprecated when using the 'GetMetadataAsync' method: True
Package Cake.Tfs deprecated when using the 'SearchAsync' method: False

As you can see, the result is different based on how the metadata was obtained. My expectation is that the deprecation information should be the same no matter how I retrieve the package metadata.

The code sample I presented in this issue is a simplified version of my actual scenario. In my scenario I use the SearchAsync method to retrieve the metadata about several packages (about 400 or so) so I would hate to have to loop through a list of 400 package and invoke the GetMetadataAsync for each one. I was really hoping to get the deprecation information along with the metadata when searching.

@zivkan zivkan added Resolution:BlockedByExternal Progress on this task is blocked by an external issue. When that issue is completed this can proceed NuGet API Type:Feature labels Oct 17, 2019
@zivkan zivkan added this to the Backlog milestone Oct 17, 2019
@zivkan
Copy link
Member

zivkan commented Oct 17, 2019

@Jericho nuget.org doesn't provide deprecation information in their search results (you can check Fiddler, or open the search URL in your browser).

This appears to be the server team's issue to track the feature: NuGet/NuGetGallery#7297

@Jericho
Copy link
Author

Jericho commented Oct 18, 2019

Thank you for the information. I’ll monitor the status of the issue you linked. In the mean time, I guess my only alternative is to loop through the 400 or so packages and fetch the metadata for each one and hope that I don’t trigger nuget’s abuse detection.

@nkolev92
Copy link
Member

hope that I don’t trigger nuget’s abuse detection.

You should be fine there, as long as you are using the metadata resource :)

@nkolev92
Copy link
Member

nkolev92 commented May 7, 2020

Closing this as dup of NuGet/NuGetGallery#7297 as it's not actionable.

We will look into this again once the server has fixed the experience.

@nkolev92 nkolev92 closed this as completed May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:SDK The NuGet client packages published to nuget.org Resolution:BlockedByExternal Progress on this task is blocked by an external issue. When that issue is completed this can proceed Type:Feature
Projects
None yet
Development

No branches or pull requests

4 participants