praeclarum / FuGetGallery

An alternative web UI for browsing nuget packages
https://www.fuget.org
MIT License
683 stars 121 forks source link

Allow 'totalDownloads' to be missing from search results JSON #88

Closed bgrainger closed 4 years ago

bgrainger commented 4 years ago

Azure Artifacts supports the v3 NuGet Search API, but doesn't return a totalDownloads property for each package. (I can't provide an example URL, sorry.) We now just set this property (which isn't currently used) to zero if it's missing in the JSON.

Without this change, searching displays the following error in the UI:

System.ArgumentNullException: Value cannot be null. Parameter name: value at Newtonsoft.Json.Linq.JToken.EnsureValue(JToken value) at Newtonsoft.Json.Linq.JToken.op_Explicit(JToken value) at FuGetGallery.PackagesSearchResults.Read(String json) in C:\Code\FuGetGallery\Data\PackagesSearchResults.cs:line 45 at FuGetGallery.PackagesSearchResults.ResultsCache.GetValueAsync(String q, HttpClient httpClient, CancellationToken token) in C:\Code\FuGetGallery\Data\PackagesSearchResults.cs:line 87