Docker.DotNet icon indicating copy to clipboard operation
Docker.DotNet copied to clipboard

3.125.4 dockerClient.System.GetSystemInfoAsync() JsonSerializationException

Open thnk2wn opened this issue 5 years ago • 12 comments

Upgraded Docker.Net from 3.125.2 to 3.125.4. Now getting a JsonSerializationException when calling dockerClient.System.GetSystemInfoAsync().

Output of dotnet --info:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.401
 Commit:    5b6f5e5005

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19041
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.401\

Host (useful for support):
  Version: 3.1.7
  Commit:  fcfdef8d6b

.NET Core SDKs installed:
  2.1.801 [C:\Program Files\dotnet\sdk]
  2.1.802 [C:\Program Files\dotnet\sdk]
  2.2.401 [C:\Program Files\dotnet\sdk]
  3.1.102 [C:\Program Files\dotnet\sdk]
  3.1.201 [C:\Program Files\dotnet\sdk]
  3.1.301 [C:\Program Files\dotnet\sdk]
  3.1.302 [C:\Program Files\dotnet\sdk]
  3.1.401 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

What version of Docker.DotNet?:

3.125.4

Steps to reproduce the issue:

  1. Call SystemInfoResponse systemInfo = await _dockerClient.System.GetSystemInfoAsync();

What actually happened?:

Received error:

Newtonsoft.Json.JsonSerializationException
  HResult=0x80131500
  Message=Error converting value "MBMxETAPBgNVBAMTCHN3YXJtLWNh" to type 'System.Collections.Generic.IList`1[System.Byte]'. Path 'Swarm.Cluster.TLSInfo.CertIssuerSubject', line 1, position 3090.
  Source=Newtonsoft.Json
  StackTrace:
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Docker.DotNet.JsonSerializer.DeserializeObject[T](String json)
   at Docker.DotNet.SystemOperations.d__5.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Boondocks.Agent.Implementation.Metrics.ContainerStatsService.d__13.MoveNext() in C:\Users\geoff.hudik\Repos\Boondocks-IOT\Agent\src\Boondocks.Agent\Implementation\Metrics\ContainerStatsService.cs:line 107

  This exception was originally thrown at this call stack:
    Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(object, System.Type, System.Type)
    Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(object, System.Globalization.CultureInfo, System.Type)
    Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(Newtonsoft.Json.JsonReader, object, System.Globalization.CultureInfo, Newtonsoft.Json.Serialization.JsonContract, System.Type)

Inner Exception 1:
ArgumentException: Could not cast or convert from System.String to System.Collections.Generic.IList`1[System.Byte].

What did you expect to happen?:

Expected populated docker system info object that the last version returned.

Additional information:

Platform: Microsoft Windows 10.0.19041

Not sure if it's relevant but do have these versions of Newtonsoft.Json in the same project:

<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.2" />

Docker system info: docker-system-info.json.txt

thnk2wn avatar Aug 13 '20 19:08 thnk2wn

Getting the same error with Swarm.ListNodesAsync() in version 3.125.4

The-TT-Hacker avatar Aug 28 '20 08:08 The-TT-Hacker

In this class here: https://github.com/dotnet/Docker.DotNet/blob/master/src/Docker.DotNet/Models/TLSInfo.Generated.cs

CertIssuerSubject is a List

It appears in the JSON returned from the docker engine as a string:

"CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh"

Not sure why this is being deserialised to a list of bytes.

The-TT-Hacker avatar Aug 28 '20 12:08 The-TT-Hacker

hi, I'm having the same issue "CertIssuerSubject": "MBMxETAPBgNVBAMTCHN3YXJtLWNh" with version 3.125.4 Swarm.ListNodesAsync() Swarm.InspectSwarmAsync() Swarm.ListServicesAsync()

Can you please possibly do a fix?

Thanks in advance.

gurelsoycaner avatar Sep 03 '20 06:09 gurelsoycaner

The JSON models are generated, does anyone know how this is done? Or maybe the problem is we just need a JsonConverter for base64 to byte array

The-TT-Hacker avatar Sep 03 '20 06:09 The-TT-Hacker

The JSON models are generated, does anyone know how this is done? Or maybe the problem is we just need a JsonConverter for base64 to byte array

Why not just download the code and fix it locally by changing CertIssuerPublicKey to string in Docker.DotNet.Models TLSInfo class. I'm not sure this is the right way, but it works for me.

gurelsoycaner avatar Sep 04 '20 06:09 gurelsoycaner

Yeah that will fix it, but I don't think that change would get merged in if you submitted a pull request. That class is code generated based off the docker API schema.

Edit: I'll just submit one and we'll see what happens. This really needs to be fixed, the repo is broken and the previous version is missing quite a few features.

The-TT-Hacker avatar Sep 04 '20 07:09 The-TT-Hacker

I just submitted this pull request: https://github.com/dotnet/Docker.DotNet/pull/469 adding a simple json converter seems to have fixed the problem for me

The-TT-Hacker avatar Oct 09 '20 04:10 The-TT-Hacker

@thnk2wn this should have be fixed in last version as @The-TT-Hacker contribution has been merged

dgvives avatar Jan 30 '21 16:01 dgvives

@dgvives how can we bring #469 forward? This is a blocking issue for me

lippertmarkus avatar Mar 28 '21 13:03 lippertmarkus

It is fixed on master branch. Include the library not from nuget but from source code

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Markus Lippert @.> Sent: Sunday, March 28, 2021 3:30:25 PM To: dotnet/Docker.DotNet @.> Cc: David García Vives @.>; Mention @.> Subject: Re: [dotnet/Docker.DotNet] 3.125.4 dockerClient.System.GetSystemInfoAsync() JsonSerializationException (#458)

@dgviveshttps://github.com/dgvives how can we bring #469https://github.com/dotnet/Docker.DotNet/pull/469 forward? This is a blocking issue for me

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/Docker.DotNet/issues/458#issuecomment-808897448, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARATUNYLCWOV6PK7ZCZCCDLTF44QDANCNFSM4P6Y73LQ.

dgvives avatar Mar 28 '21 15:03 dgvives

Any update about when a fix for this issue is going to be released?

jcfiorenzano avatar Jun 04 '21 00:06 jcfiorenzano

Any update about when a fix for this issue is going to be released?

I also would love to see the fix in a versioned package on nuget.org.

breigo avatar Jul 28 '21 18:07 breigo