dotnet-delice icon indicating copy to clipboard operation
dotnet-delice copied to clipboard

Unhandled nullpointerexception running in Jenkins

Open ulrik-nilsson opened this issue 4 years ago • 5 comments

i get an unhandled exception in Jenkins running path/to/dotnet-delice.dll path/to/project.csproj --check-github --github-token github-token --check-license-content --refresh-spdx --json-output path/to/output/licenses.json -j

The same command works on my local machine. I have tried changing both csproj and output to paths I know is wrong and then I get other errors. I realize its something in our Jenkins environment that cause this but it would be nice to check the input values here and throw an Exception with more information.

I have looked at the code but are not enough familiar with F# to determine what cause the exception, do you have any idea what it could be?

Stacktrace:
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
at App.getLicenses(Boolean checkGitHub, String token, Boolean checkLicenseContent, PackageSpec projectSpec) in /home/runner/work/dotnet-delice/dotnet-delice/src/DotNetDelice/App.fs:line 40
at App.getLicenses'@124.Invoke(PackageSpec projectSpec) in /home/runner/work/dotnet-delice/dotnet-delice/src/DotNetDelice/App.fs:line 124
at [email protected](PackageSpec projectSpec) in /home/runner/work/dotnet-delice/dotnet-delice/src/DotNetDelice/App.fs:line 139
at Microsoft.FSharp.Collections.Internal.IEnumerator.map@75.DoMoveNext(b& curr) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 78
at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System.Collections.IEnumerator.MoveNext() in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 64
at Microsoft.FSharp.Collections.Generator.Microsoft-FSharp-Collections-Generator-Generator<'T>[email protected](Unit unitVar0) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 421
at Microsoft.FSharp.Collections.Generator.appG[a](Generator`1 g) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\seq.fs:line 316
at Microsoft.FSharp.Collections.Generator.EnumeratorWrappingLazyGenerator`1.System.Collections.IEnumerator.MoveNext()
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at JsonOutput.jsonPrinter(String path, IEnumerable`1 json) in /home/runner/work/dotnet-delice/dotnet-delice/src/DotNetDelice/JsonOutput.fs:line 99
--- End of stack trace from previous location ---
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Program.main(String[] args) in /home/runner/work/dotnet-delice/dotnet-delice/src/DotNetDelice/Program.fs:line 9

ulrik-nilsson avatar May 03 '21 09:05 ulrik-nilsson

Is it able to dump out the non-JSON version on the build server?

It's most likely that some license fails to build an object graph, but I'm not sure how that'd be.

Alternatively, are you able to provide a list of PackageReference's that are used?

aaronpowell avatar May 11 '21 06:05 aaronpowell

Had to take it away from the build pipeline and will not have time to lock at it until next month, will come back to you then

ulrik-nilsson avatar May 18 '21 08:05 ulrik-nilsson

I missed your second question last time, here are the PackageReferences:

<PackageReference Include="Avalonia" Version="0.8.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.8.0" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.8.0" />
<PackageReference Include="CommandLineParser" Version="2.5.0" />
<PackageReference Include="Fody" Version="6.5.1">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="NSubsys" Version="1.0.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="ReactiveUI.Fody" Version="13.2.18" />
<PackageReference Include="ReactiveUI.Validation" Version="1.1.1" />

I'll see if I can get the dump aswell

ulrik-nilsson avatar Jul 12 '21 05:07 ulrik-nilsson

Thanks, I'll see if I can repo it myself

aaronpowell avatar Jul 12 '21 07:07 aaronpowell

Found the reason now, the project failing wasnt built when it ran on Jenkins and therefore GetLockFile returned null.

Adding a null check and instructive error message could be helpful there, thanks for answering quickly anyways!

ulrik-nilsson avatar Jul 12 '21 11:07 ulrik-nilsson