While performing an updateItem operation to a dynamo table using the AWS Javascript SDK, I am instead seeing a second row written with the same primary key, which certainly seems contrary to the documentation.
I am using a hash string key "user_id".
The initial write:
var params = {
Item: {
user_id : {S: "foo"},
is_authorized: {BOOL: false},
},
TableName: 'MyTable'
};
db.putItem(params, function(err, data){
if(err){
console.log(err);
}else{
console.log(data);
}
});
The Update Attempt
var updateParams = {
Key: {
user_id : {S: "foo"},
},
AttributeUpdates: {
confirmationCode: {Action: "PUT", Value: {S: "key"}},
phone: {Action: 'PUT', Value: {S: "1234567}},
is_authorized: {Action: 'PUT', Value: {BOOL: false}},
confirmAttempts: {Action: 'PUT', Value: {N: "1"}}
},
TableName: 'MyTable'
};
db.updateItem(params, function(err, data){
if(err){
response = err;
console.log("The error was: " + err);
}else{
response = data;
console.log(data);
}
});
For reference to others who might come across this issue:
This issue was caused by whitespace, specifically a trailing space at the end of some primary key strings. Viewing Dynamo records, at least from within the console, does not convert whitespace characters, so it was an invisible issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With