I was trying to configure DAX for an existing Lambda function that reads and writes data to DynamoDB. Before introducing DAX everything worked ok, after that, the writes stopped working, with no change in what data was being written.

On debug, I found out that they fail with this exception:

Write operation failed without negative acknowledgement 
Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Function._encodeAttributeValueInternal (/var/task/node_modules/amazon-dax-client/src/AttributeValueEncoder.js:173:23)
at Function.encodeAttributes (/var/task/node_modules/amazon-dax-client/src/AttributeValueEncoder.js:144:29)
at Function.encodeValuesWithNames (/var/task/node_modules/amazon-dax-client/src/Encoders.js:227:55)
at Encoders.encodeValues (/var/task/node_modules/amazon-dax-client/src/Encoders.js:67:23)
at Promise.resolve.then (/var/task/node_modules/amazon-dax-client/generated-src/Stubs.js:163:24)
at propagateAslWrapper (/var/task/node_modules/async-listener/index.js:504:23)
at /var/task/node_modules/async-listener/glue.js:188:31
at /var/task/node_modules/async-listener/index.js:541:70
at /var/task/node_modules/async-listener/glue.js:188:31

1 Answers

0
Andy On

The data being written had some fields that were "optional". The Item being written was like:

{
    requiredField1: "Some value",
    requiredField2: true,
    optionalField1: "abc",
    optionalField2: null,
    optionalField3: undefined,
}

Everything was fine and dandy with DynamoDB, no complains, but apparently DAX is unforgiving with the undefined. Changing that to null got me past the error.