DynamoDb documentClient.update or delete StringSet throws ValidationException

754 Views Asked by At

I successfully update and delete an item from a StringSet in a dynamoDb table when called from my test app running on localhost.

I then upload the app to LightSail but now when I call the same function to update or delete an item it throws a ValidationException!:

{
"message": "Invalid UpdateExpression: Incorrect operand type for operator or 
function; operator: DELETE, operand type: MAP",
"code": "ValidationException",
"time": "2018-01-03T13:20:14.919Z",
"requestId": "9HCQMH5RAUBRK1K7BNESNBUD5BVV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 10.381373865940402
}

Why? I have not made any changes to my code so why does this happen and how to solve it?

Here's the relevant code:

var documentClient = getDocumentClient();

var paramsSET = {
ExpressionAttributeNames:
{
  "#StringSet": "Packages"
},
ExpressionAttributeValues:
{
  ":value": documentClient.createSet(['filler as SET cannot be empty',
    app.packageName
  ])
},
Key:
{
  "EmailAddress": app.emailAddress
},
ReturnValues: "ALL_NEW",
TableName: "Developers",
UpdateExpression: "ADD #StringSet :value"
  // UpdateExpression: "DELETE #StringSet :value" ------ to delete value
};
  // adds packagename to Packages SET in developers table - creates set if not exist
documentClient.update(paramsSET, function (err, data){}
1

There are 1 best solutions below

0
On

I could not get it to work using the documentclient api.

finally used the old api and got it to work using dynamodb.updateItem see docs here

still have no idea why it works on localhost (accessing the same dynamodb tables) and not when live on LightSail!