aaaristo Github contribution chart
aaaristo Github Stats
aaaristo Most Used Languages

Activity

11 Aug 2022

Issue Comment

Aaaristo

marshallInput fails to marshall AttributeUpdates for map attributes

Checkboxes for prior research

Describe the bug

marshallInput({ AttributeUpdates: { customer: { Action: "PUT", Value: { first_name: 'Andrea', last_name: 'Gariboldi' } } } }, [{"key":"AttributeUpdates","children":{"children":[{"key":"Value"}]}}])) 

returns

{"AttributeUpdates":{"customer":{"Action":"PUT","Value":{"first_name":{"S":"Andrea"},"last_name":{"S":"Gariboldi"}}}}} 

But it should return

{"AttributeUpdates":{"customer":{"Action":"PUT","Value":{ "M": {"first_name":{"S":"Andrea"},"last_name":{"S":"Gariboldi"}}}}}} 

Then it fails shortly after due to the fact that Value has an unknown type

TypeError: Cannot read property '0' of undefined
  at Object.AttributeValue.visit (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/models/models_0.js:457:40)
  at serializeAws_json1_0AttributeValue (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3025:38)
  at serializeAws_json1_0AttributeValueUpdate (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3049:45)
  at /code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3020:20
  at Array.reduce (<anonymous>)
  at serializeAws_json1_0AttributeUpdates (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3014:34)
  at serializeAws_json1_0UpdateItemInput (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:4216:31)
  at serializeAws_json1_0UpdateItemCommand (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:476:27)
  at serialize (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/commands/UpdateItemCommand.js:30:72)
  at /code/api/node_modules/@aws-sdk/middleware-serde/dist-cjs/serializerMiddleware.js:5:27
  at /code/api/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/baseCommand/DynamoDBDocumentClientCommand.js:11:20 

SDK version number

@aws-sdk/lib-dynamodb@3.142.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v14.18.1

Reproduction Steps

JSON.stringify(require('./node_modules/@aws-sdk/lib-dynamodb/dist-cjs/commands/utils.js').marshallInput({ AttributeUpdates: { customer: { Action: "PUT", Value: { first_name: 'Andrea', last_name: 'Gariboldi' } } } }, [{"key":"AttributeUpdates","children":{"children":[{"key":"Value"}]}}])) 

Observed Behavior

I got his error while trying to update an object with the document client

TypeError: Cannot read property '0' of undefined
  at Object.AttributeValue.visit (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/models/models_0.js:457:40)
  at serializeAws_json1_0AttributeValue (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3025:38)
  at serializeAws_json1_0AttributeValueUpdate (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3049:45)
  at /code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3020:20
  at Array.reduce (<anonymous>)
  at serializeAws_json1_0AttributeUpdates (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:3014:34)
  at serializeAws_json1_0UpdateItemInput (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:4216:31)
  at serializeAws_json1_0UpdateItemCommand (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:476:27)
  at serialize (/code/api/node_modules/@aws-sdk/client-dynamodb/dist-cjs/commands/UpdateItemCommand.js:30:72)
  at /code/api/node_modules/@aws-sdk/middleware-serde/dist-cjs/serializerMiddleware.js:5:27
  at /code/api/node_modules/@aws-sdk/lib-dynamodb/dist-cjs/baseCommand/DynamoDBDocumentClientCommand.js:11:20 

Expected Behavior

It is possible to set map attributes using the document client on a dynamodb item

Possible Solution

No response

Additional Information/Context

No response

Forked On 11 Aug 2022 at 05:29:10

Aaaristo

The output above is not correct, you are trying to set a map attribute. And it will fail if you try to send an actual UpdateItem command.

Commented On 11 Aug 2022 at 05:29:10

Aaaristo

fix: attribute updates via document client

Created On 09 Aug 2022 at 04:08:10
Create Branch
Aaaristo In aaaristo/aws-sdk-js-v3 Create Branchfix-attribute-updates

Aaaristo

Modularized AWS SDK for JavaScript.

On 09 Aug 2022 at 04:05:44

Aaaristo

Modularized AWS SDK for JavaScript.

Forked On 09 Aug 2022 at 03:57:49