我试图为现有的Lambda函数配置DAX,该函数可将数据读取和写入DynamoDB。在引入DAX之前,一切正常,然后,写入停止工作,正在写入的数据保持不变。
在调试时,我发现它们因以下异常而失败:
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
答案 0 :(得分:0)
正在写入的数据具有一些“可选”字段。所写的项目就像:
{
requiredField1: "Some value",
requiredField2: true,
optionalField1: "abc",
optionalField2: null,
optionalField3: undefined,
}
DynamoDB的一切都很好,很花哨,没有抱怨,但是显然DAX对undefined
并不宽容。将其更改为null
使我克服了错误。