aboutcode-org / aboutcode-org/nuget-inspector

NullReferenceException when getting remote metadata

Offen
#78 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
5
Forks
13
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

We are using nuget-inspector (orchestrated by ORT) in version 0.10.0 to analyze a project that declares a private source repository. The tool is invoked as follows:

```
nuget-inspector --with-details --verbose --project-file Project.csproj --json /tmp/nuget-inspector-output.json
```
The invocation is successful, but for some packages no metadata can be retrieved, and warnings like the one below are issued for those packages:

```
WARNING: Failed to get remote metadata for name: 'Newtonsoft.Json' version: '13.0.4'. System.NullReferenceException: Object reference not set to an instance of an object.
at NugetInspector.NugetApi.GetPackageDownload(PackageIdentity identity, Boolean with_details) in ./nuget-inspector/NugetApi.cs:line 542
at NugetInspector.BasePackage.UpdateWithRemoteMetadata(NugetApi nugetApi, Boolean with_details) in ./nuget-inspector/Models.cs:line 349
at NugetInspector.BasePackage.Update(NugetApi nugetApi, Boolean with_details) in ./nuget-inspector/Models.cs:line 321
```
According to my analysis, the problem seems to be that the private repository (hosted on JFrog Artifactory) does not return a value for the optional `CatalogUri` property. The code that raises the exception, method `GetPackageDownload()` in `NugetApi.cs` in line 542, accesses this property without a null check:

```
PackageSearchMetadataRegistration? registration = FindPackageVersion(identity);
if (registration == null)
return download;

var package_catalog_url = registration.CatalogUri.ToString(); // <-- Line 542, NRE here
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.