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

In RabbitMQ 3.12.10 Queue.ConsumerDetails[].ChannelDetail.Name can be null #306

Closed
inikulshin opened this issue Jan 11, 2024 · 3 comments
Closed

Comments

@inikulshin
Copy link
Contributor

In RabbitMQ 3.12.10 (+ EasyNetQ.Management.Client 3.0.0-alpha5) Queue.ConsumerDetails[].ChannelDetail.Name can be null:

System.ArgumentNullException: [NullGuard] Name is null.
Parameter name: Name
   at EasyNetQ.Management.Client.Model.ChannelDetail..ctor(String Name, Int32 Number, String User, String ConnectionName, Int32 PeerPort, String PeerHost, String Node)
   at .ctor(Object[] )
   at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.CreateObject(ReadStackFrame& frame)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadUsingMetadata[TValue](JsonElement element, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](JsonElement element, JsonSerializerOptions options)
   at EasyNetQ.Management.Client.Serialization.EmptyArrayAsDefaultConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryReadAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state, Object& value)
   at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.ReadConstructorArgumentsWithContinuation(ReadStack& state, Utf8JsonReader& reader, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonCollectionConverter`2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryReadAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state, Object& value)
   at System.Text.Json.Serialization.Converters.LargeObjectWithParameterizedConstructorConverter`1.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.ReadConstructorArgumentsWithContinuation(ReadStack& state, Utf8JsonReader& reader, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.<ReadFromStreamAsync>d__76`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Net.Http.Json.HttpContentJsonExtensions.<ReadFromJsonAsyncCore>d__5`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at EasyNetQ.Management.Client.ManagementClient.<GetAsync>d__108`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at EasyNetQ.Management.Client.ManagementClientExtensions.GetQueue(IManagementClient client, Vhost vhost, String queueName, LengthsCriteria lengthsCriteria, RatesCriteria ratesCriteria, CancellationToken cancellationToken)
@inikulshin
Copy link
Contributor Author

inikulshin commented Jan 14, 2024

Ok, the issue much more global than I thought. @Pliner, thanks for asking for a reproduction. :)

I caught an exception from ReadFromJsonAsync:

System.Text.Json.JsonException: EasyNetQ JSON scheme doesn't match actual RabbitMQ response content: {"garbage_collection":{"max_heap_size":-1,"min_bin_vheap_size":-1,"min_heap_size":-1,"fullsweep_after":-1,"minor_gcs":-1},"consumer_details":[{"arguments":{},"channel_details":{},"ack_required":true,"active":true,"activity_status":"up","consumer_tag":"1","consumer_timeout":"undefined","exclusive":false,"prefetch_count":0,"queue":{"name":"vsb.topic=Filtering_13","vhost":"TLS_B"}}],"arguments":{"x-max-priority":4},"auto_delete":false,"deliveries":[],"durable":true,"exclusive":false,"incoming":[],"name":"vsb.topic=Filtering_13","node":"rabbit@localhost","type":"classic","vhost":"TLS_B"}

The interesting part of it is "channel_details":{}

I think, we should fix EmptyArrayAsDefaultConverter with

            case { ValueKind: JsonValueKind.Object } when jsonElement.EnumerateObject().Any():
                return jsonElement.Deserialize<T>(options);

            case { ValueKind: JsonValueKind.Object }:
                return default;

Or create new EmptyArrayOrObjectAsDefaultConverter converter?

What do you think?

@inikulshin
Copy link
Contributor Author

The same happened to "arguments": {}, which is also defined with EmptyArrayAsDefaultConverter converter

    [property: JsonConverter(typeof(EmptyArrayAsDefaultConverter<ConsumerArguments>))]
    ConsumerArguments? Arguments,

Formatted response:

{
  "garbage_collection": {
    "max_heap_size": -1,
    "min_bin_vheap_size": -1,
    "min_heap_size": -1,
    "fullsweep_after": -1,
    "minor_gcs": -1
  },
  "consumer_details": [
    {
      "arguments": {},
      "channel_details": {},
      "ack_required": true,
      "active": true,
      "activity_status": "up",
      "consumer_tag": "1",
      "consumer_timeout": "undefined",
      "exclusive": false,
      "prefetch_count": 0,
      "queue": {
        "name": "vsb.topic=Filtering_13",
        "vhost": "TLS_B"
      }
    }
  ],
  "arguments": {
    "x-max-priority": 4
  },
  "auto_delete": false,
  "deliveries": [],
  "durable": true,
  "exclusive": false,
  "incoming": [],
  "name": "vsb.topic=Filtering_13",
  "node": "rabbit@localhost",
  "type": "classic",
  "vhost": "TLS_B"
}

@inikulshin
Copy link
Contributor Author

inikulshin commented Jan 15, 2024

Fixed in #309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant