fix(lib-dynamodb): fix marshalling of list attributes in UpdateCommand #3719
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I recently found a bug in the
@aws-sdk/lib-dynamodb
package (document client) . The UpdateCommand was failing when providing a list attribute to AttributeUpdates. UpdateCommand allows you to supply native attribute values to update a dynamo record like so:The issue I was running in to was that list attributes were not being marshaled properly and causing a JSON parsing error downstream in the library. The marshaler would convert the above AttributeUpdates map into:
The dynamodb client expects lists to also be prefaced with an attribute type like so
This PR addresses the issue in the lib-dynamo marshaling code so that lists are passed properly to the dynamodb client. I added an optional parameter to the KeyNode type so that this only affects commands that need to process nodes in this fashion.
Testing
I wrote unit tests to ensure that the marshaling works properly and ran the entire test suite to test for breaking changes.
Additional Context
I could not regenerate clients due to
Projection ec2.2016-11-15 failed: java.lang.OutOfMemoryError: Java heap space
. I don't believe this was caused by my changes as I did not touch any EC2 code.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.