The Problem:
I'm struggling with the updateItem instruction in AWS' dynamoDB. So far as I can tell, I've written the code precisely as illustrated in the documentation and as directed by an Amazon support tech. Nonetheless, I receive an error message with 13 validation errors. They don't make sense to me.
What I've Done So Far:
I've searched StackOverflow and read the few AWS DynamoDB questions. None was on point. I searched the web generally and found no help. I've been reading the AWS DynamoDB reference material, but it's dense, and the going is slow. I'm still working on that.
I constructed this codepen minCase pin.
Any help will be appreciated in the extreme.
The JavaScript Code
var dynamoDB = new AWS.DynamoDB();
params0 = {
'TableName': 'FHCRoomCounts',
'Key': {
timeSlot: '0830',
room: 'chapel',
},
'UpdateExpression': 'ADD registrants :n',
'ExpressionAttributeValues': {
':n' : 1,
},
'ReturnValues': 'ALL_NEW'
};
console.log('log params0 : ');
for(let [key, value] of Object.entries(params0)) {
console.log(key, value);
} // end for-let
console.log('calling dynamoDB.updateItem');
dynamoDB.updateItem(params0, function(err, data) {
if (err) {
console.log('Unable to update registrant: ' + '\n' + JSON.stringify(err, undefined, 2));
} else {
console.log('Increase registrant succeeded: ' + '\n' + JSON.stringify(data, undefined, 2));
} // end else
The Error Message: 13 Validation Errors.
Following is the console log. I logged the params object so that you could see what was being submitted to AWS.
jquery loaded
AWS sdk loaded
log params0 :
TableName FHCRoomCounts
Key Object { timeSlot: "0830", room: "chapel" }
UpdateExpression ADD registrants :n
ExpressionAttributeValues Object { ":n": 1 }
ReturnValues ALL_NEW
calling dynamoDB.updateItem
Unable to update registrant:
{
"message": "There were 13 validation errors:\n*
InvalidParameterType: Expected params.Key['timeSlot'] to be a structure\n* UnexpectedParameter: Unexpected key '0' found in params.Key['timeSlot']\n* UnexpectedParameter: Unexpected key '1' found in params.Key['timeSlot']\n* UnexpectedParameter: Unexpected key '2' found in params.Key['timeSlot']\n* UnexpectedParameter: Unexpected key '3' found in params.Key['timeSlot']\n* InvalidParameterType: Expected params.Key['room'] to be a structure\n* UnexpectedParameter: Unexpected key '0' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '1' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '2' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '3' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '4' found in params.Key['room']\n* UnexpectedParameter: Unexpected key '5' found in params.Key['room']\n* InvalidParameterType: Expected params.ExpressionAttributeValues[':n'] to be a structure",
"code": "MultipleValidationErrors",
"errors": [
{
"message": "Expected params.Key['timeSlot'] to be a structure",
"code": "InvalidParameterType",
"time": "2019-06-15T04:51:05.288Z"
},
{
"message": "Unexpected key '0' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Unexpected key '1' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Unexpected key '2' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Unexpected key '3' found in params.Key['timeSlot']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.289Z"
},
{
"message": "Expected params.Key['room'] to be a structure",
"code": "InvalidParameterType",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '0' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '1' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '2' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '3' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '4' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Unexpected key '5' found in params.Key['room']",
"code": "UnexpectedParameter",
"time": "2019-06-15T04:51:05.290Z"
},
{
"message": "Expected params.ExpressionAttributeValues[':n'] to be a structure",
"code": "InvalidParameterType",
"time": "2019-06-15T04:51:05.291Z"
}
],
"time": "2019-06-15T04:51:05.291Z",
"stack": "validate@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:61:19246\n[311]</a.EventListeners.Core</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25947\ncallListeners@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26769\ns@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26635\n[311]</a.EventListeners.Core</</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25280\nt@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25669\ngetCredentials/</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25990\nget@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:30534\ngetCredentials/<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25896\ngetCredentials@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:59:25997\n[311]</a.EventListeners.Core</<@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:60:25149\ncallListeners@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26740\nemit@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:26480\nemitEvent@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:12277\ne@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:7919\n[363]</i.prototype.runTo@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:64:9533\nrunTo@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:9575\nsend@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:9468\nmakeRequest@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:62:30482\ndefineMethods/</e.prototype[t]@https://sdk.amazonaws.com/js/aws-sdk-2.470.0.min.js:63:5136\nupdateTable@https://steve-alexander-pfmi.squarespace.com/test-register-2019:110:12\n"
}