-
Notifications
You must be signed in to change notification settings - Fork 483
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
DynamoDb record deserialization does not work with empty Map values #1888
Comments
@danny-zegel-zocdoc Good afternoon. I used the below code for reproducing the issue: public void FunctionHandlerNew(DynamoDBEvent input, ILambdaContext context)
{
context.Logger.LogLine("OK");
} with the below event payload: {
"Records": [
{
"awsRegion": "us-east-1",
"eventID": "9b997d0a-9512-46b7-a239-093431b36204",
"eventName": "MODIFY",
"userIdentity": null,
"recordFormat": "application/json",
"dynamodb": {
"ApproximateCreationDateTime": 1732710435144,
"Keys": {
"PK": {
"S": "my pk value"
},
"SK": {
"S": "my sk value"
}
},
"NewImage": {
"MyData": {
"M": {
"Selections": {
"M": {}
}
}
},
"SK": {
"S": "my sk value"
},
"PK": {
"S": "my pk value"
}
},
"OldImage": { },
"SizeBytes": 30
},
"eventSource": "aws:dynamodb"
}
]
} Inspecting the value of
The dependency on SDK was removed in 4329775 where it now uses it's own I notice that you are using Are you expecting I'm unsure if we should be returning Thanks, |
Thanks you for the response @ashishdhingra Being that DynamoDb does support empty Map values (unlike string set as DDB does not support empty sets) I would expect the SDK to respect it as well and differentiate between nulls and empty dictionaries. In regards to the AttributeValue implementation, it does contain the IsMSet property which is backed by InternalSDKUtils.GetIsSet and InternalSDKUtils.SetIsSet which utilizes the Seems to me there are a couple easy options for the fix:
just my 2 cents but the first option i described is likely less risky but the second one would make this work as expected out of the box for arbitrary serializers (say someone wanted to use Newtonsoft or whatever). This also seems to be a problem for |
@ashishdhingra regarding your point about the dependency changes and using However I'm using the deserialized output with |
If such a JsonConverter were just made available I could add it to an instance of |
Closing up on this issue. The types in the SDK like Due to the SDK's pattern of initializing all collection properties to an empty collection we have to have all of the IsSet properties which are managed by the SDK's marshallers. When using a plan Json serializer it wouldn't know how to handle the IsSet properties. In the upcoming V4 of the SDK we are changing the SDK's behavior to have collection properties initialized to null. In that case the There are no plans to focus on making SDK types compatible as Lambda events. That is a contract we are not comfortable making. What it sounds like you need is for use to make some progress on this issue requesting a |
Comments on closed issues are hard for our team to see. |
Describe the bug
When using
DefaultLambdaJsonSerializer
to deserialize DynamoDb events that have nested Map type attributes that are empty it parses themAttributeValue
objects that don't have any value set.for example the following payload
deserialized
![Screenshot 2024-11-27 at 4 24 43 PM](https://private-user-images.githubusercontent.com/14278106/390448159-527d127b-91dd-4a44-b45e-11853b4073fd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNjkwODgsIm5iZiI6MTczOTE2ODc4OCwicGF0aCI6Ii8xNDI3ODEwNi8zOTA0NDgxNTktNTI3ZDEyN2ItOTFkZC00YTQ0LWI0NWUtMTE4NTNiNDA3M2ZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDA2MjYyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhNzRmYWUyYTdiYmJkYjA3MmJmMDg0ZTQyOGRhZThjNDAyMmQ4YzczODNhMzY0Y2JkNTU4OWY4ZTEzMjM4NjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.UAG-oEyy_R3faOIpDeM1JGrRQN3xBayDEG2-ONLD56o)
Selections
to anAttributeValue
object with nothing setRegression Issue
Expected Behavior
I would expect
DefaultLambdaJsonSerializer
to Deserialize empty Maps toAttributeValue
objects withIsMSet
set totrue
.Current Behavior
DefaultLambdaJsonSerializer
Deserializes empty Maps toAttributeValue
objects withIsMSet
set tofalse
.Reproduction Steps
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
Amazon.Lambda.Serialization.SystemTextJson Version 2.4.4
AWSSDK.DynamoDBv2 Version 3.7.301.10
Targeted .NET Platform
.NET 8
Operating System and version
macOS Somona
The text was updated successfully, but these errors were encountered: