Error in DateTime when using BatchWrite
See original GitHub issueHi I’m getting an exception:
“EfficientDynamoDb.Exceptions.DdbException: SerializationException
at EfficientDynamoDb.Internal.ErrorHandler.ProcessErrorAsync(DynamoDbContextMetadata metadata, HttpResponseMessage response, CancellationToken cancellationToken)
at EfficientDynamoDb.Internal.ErrorHandler.ProcessErrorAsync(DynamoDbContextMetadata metadata, HttpResponseMessage response, CancellationToken cancellationToken)
at EfficientDynamoDb.Internal.ErrorHandler.ProcessErrorAsync(DynamoDbContextMetadata metadata, HttpResponseMessage response, CancellationToken cancellationToken)
at EfficientDynamoDb.Internal.HttpApi.SendAsync(DynamoDbContextConfig config, HttpContent httpContent, CancellationToken cancellationToken)
at EfficientDynamoDb.DynamoDbContext.BatchWriteItemAsync(BuilderNode node, CancellationToken cancellationToken)
…”
when executing
await _dBContext.BatchWrite().WithItems( Batch.PutItem(batch) ).ExecuteAsync();
Where “batch” is an array of objects that includes two DateTime properties.
I couldn’t figure out where the problem come from, there is possible to debug or view some logs to dig deeper?
When i tried update items one by one I got errors whe the Kind of the DateTime was Local. Now I changed all of the to UTC and works one by one, but not as a batch. I mention this because I thought at the beginig that could be related, but I´m not so sure anymore.
My previous comment here for reference:
"
I’m trying to execute
await _dBContext.PutItem() .WithItem(item) .ExecuteAsync();
And I’m getting this exception:
"EfficientDynamoDb.Exceptions.DdbException: Couldn't format DateTime ddb value from '26/04/2022 9:00:00'. at EfficientDynamoDb.Converters.DateTimeDdbConverter.Write(DdbWriter& writer, DateTime& value) at EfficientDynamoDb.Internal.Metadata.DdbPropertyInfo1.Write(Object obj, DdbWriter& ddbWriter) at EfficientDynamoDb.Internal.Extensions.DdbWriterExtensions.WriteEntityAsync(DdbWriter writer, DdbClassInfo entityClassInfo, Object entity) at EfficientDynamoDb.Internal.Operations.PutItem.PutItemHighLevelHttpContent.WriteDataAsync(DdbWriter ddbWriter) at EfficientDynamoDb.Internal.Operations.Shared.DynamoDbHttpContent.SerializeToStreamAsync(Stream stream, TransportContext context) at EfficientDynamoDb.Internal.Operations.Shared.DynamoDbHttpContent.SerializeToStreamAsync(Stream stream, TransportContext context) at EfficientDynamoDb.Internal.Operations.Shared.DynamoDbHttpContent.CreatePooledContentReadStreamAsync() at EfficientDynamoDb.Internal.HttpApi.SendAsync(DynamoDbContextConfig config, HttpContent httpContent, CancellationToken cancellationToken) at EfficientDynamoDb.DynamoDbContext.PutItemAsync[TEntity](BuilderNode node, CancellationToken cancellationToken) at EfficientDynamoDb.Operations.PutItem.PutItemEntityRequestBuilder1.ExecuteAsync(CancellationToken cancellationToken) ..."
the DateTime object is like this:
{26/04/2022 9:00:00} Date: {26/04/2022 0:00:00} Day: 26 DayOfWeek: Tuesday DayOfYear: 116 Hour: 9 Kind: Local Millisecond: 0 Minute: 0 Month: 4 Second: 0 Ticks: 637865604000000000 TimeOfDay: {09:00:00} Year: 2022
If a crete a new DateTime with Kind Unespecified it works fine. new DateTime(item.StartTime.Ticks, DateTimeKind.Unspecified) {26/04/2022 9:00:00} Date: {26/04/2022 0:00:00} Day: 26 DayOfWeek: Tuesday DayOfYear: 116 Hour: 9 Kind: Unspecified Millisecond: 0 Minute: 0 Month: 4 Second: 0 Ticks: 637865604000000000 TimeOfDay: {09:00:00} Year: 2022 the same if do it with UTC: {26/04/2022 9:00:00} Date: {26/04/2022 0:00:00} Day: 26 DayOfWeek: Tuesday DayOfYear: 116 Hour: 9 Kind: Utc Millisecond: 0 Minute: 0 Month: 4 Second: 0 Ticks: 637865604000000000 TimeOfDay: {09:00:00} Year: 2022 "
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Hey @javipazos, looks like there was a default converter bug causing format exceptions while saving the local dates. I have fixed it and about to release a new stable version.
I realize I wasn’t do it right. I was putting a list of items in Batch.PutItem(). I changed to do it like this and is working:
Maybe is possible to add some limitation if sending a list is a problem to avoid future errors