You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When making multiple singular calls to the statestore, each item is deserialized correctly.
Actual Behavior
When retrieving multiple items from the statestore, Dapr will not be able to deserialize the same types if there are multiples of those types in the statestore.
System.ArgumentException: An item with the same key has already been added. Key: MainApp.DTOs.ChartSectionDto
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at System.Text.Json.InterfaceConverter`1.GetCustomType(String typeName)
at System.Text.Json.InterfaceConverter`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, Boolean& isPopulatedValue)
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`1 jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.Deserialize[TValue](ReadOnlySpan`1 utf8Json, JsonSerializerOptions options)
at Dapr.Client.TypeConverters.FromJsonByteString[T](ByteString bytes, JsonSerializerOptions options)
at Dapr.Client.DaprClientGrpc.GetStateAsync[TValue](String storeName, String key, Nullable`1 consistencyMode, IReadOnlyDictionary`2 metadata, CancellationToken cancellationToken)
Steps to Reproduce the Problem
Make multiple calls into the statestore for a stored object that are all of the same type.
This shows the calls that were made. 4 were successful, and 2 failed, with the 2 being the same type as 1 of the 4 successful ones.
I think its likely the specific shape of the object, as they all inherit from a base interface that has [JsonInterfaceConverter(typeof(InterfaceConverter<ISection>))] (you can see the actual exception is coming from the interface converter), although I have not observed this before. Is there anything specific to the Dapr deserialization that could cause this?
I wrapped the calls in a semaphore as a test and it deserialized fine.
Any help is appreciated, the issue is very strange.
The text was updated successfully, but these errors were encountered:
Ignore this, the InterfaceConverter was actually a random package that was sharing the System.Text.Json namespace, removed and replaced with JsonPolymorphicType all good now.
Expected Behavior
When making multiple singular calls to the statestore, each item is deserialized correctly.
Actual Behavior
When retrieving multiple items from the statestore, Dapr will not be able to deserialize the same types if there are multiples of those types in the statestore.
Steps to Reproduce the Problem
Make multiple calls into the statestore for a stored object that are all of the same type.
This shows the calls that were made. 4 were successful, and 2 failed, with the 2 being the same type as 1 of the 4 successful ones.
I think its likely the specific shape of the object, as they all inherit from a base interface that has
[JsonInterfaceConverter(typeof(InterfaceConverter<ISection>))]
(you can see the actual exception is coming from the interface converter), although I have not observed this before. Is there anything specific to the Dapr deserialization that could cause this?I wrapped the calls in a semaphore as a test and it deserialized fine.
Any help is appreciated, the issue is very strange.
The text was updated successfully, but these errors were encountered: