EfficientDynamoDb icon indicating copy to clipboard operation
EfficientDynamoDb copied to clipboard

JsonIReadOnlyListHintDdbConverter crashes when BufferLengthHint is not available

Open zbyszekpy opened this issue 2 years ago • 0 comments

Hi,

I noticed problem during ToResponseAsync usage, JsonIReadOnlyListHintDdbConverter crashes during Items element deserialization

Code: context.Query<T> . . ToResponseAsync();

In JSON response Count element is after Items element, it causes that BufferLengthHint is 0 during deserialization. JsonIReadOnlyListHintDdbConverter is not prepared for this, it work with JsonListHintDdbConverter

Below patch with potential fix, please let me know if you accept such fix, I'll create PR

diff --git a/src/EfficientDynamoDb/Operations/Query/IterableResponse.cs b/src/EfficientDynamoDb/Operations/Query/IterableResponse.cs
--- a/src/EfficientDynamoDb/Operations/Query/IterableResponse.cs	(revision 566695abf18e7fa324618d6f933814a4b6f03ae5)
+++ b/src/EfficientDynamoDb/Operations/Query/IterableResponse.cs	(date 1661323032101)
@@ -75,7 +75,7 @@
         /// <summary>
         /// An array of item attributes that match the query criteria. Each element in this array consists of an attribute name and the value for that attribute.
         /// </summary>
-        [DynamoDbProperty("Items", typeof(JsonIReadOnlyListHintDdbConverter<>))]
+        [DynamoDbProperty("Items", typeof(JsonListHintDdbConverter<>))]
         public IReadOnlyList<TEntity> Items { get; set; } = null!;
     }
 }

zbyszekpy avatar Aug 25 '22 11:08 zbyszekpy