0

I created one item in my dynamodb and then my nodejs lambda function will keep updating access_token value inside this item. Below is the schema

{
  "service": {
    "S": "perform"
  },
  "access_token": {
    "S": "xxxxxxxxxx"
  }
}

Below are the dynamodb parameters that I will send to dynamodb update function

{
    "TableName": "Access-Token",
    "Key": {
        "service": "perform"
    },
    "UpdateExpression": "set access_token = :token",
    "ExpressionAttributeValues": {
        ":token": "xxxxxxxxxxxx"
    },
    "ReturnValues": "UPDATED_NEW"
}

But when I run the lambda function i received below error. Need help and guide on this

ValidationException: The provided key element does not match the schema

1
  • What is your primary key for the table (partition key / sort key)? Commented Feb 24, 2022 at 11:01

1 Answer 1

3

It is likely that you are trying to insert a record which does not have all the key elements.

If your primary key is a combination of the partition/hash key and range/sort key, you need to include both in your Key attribute in the update or put parameters.

Looks like the key service is your Partition key and the key access_token is your Sort key.

To do a update you need to send both keys:

"Key": {
    "service": "perform",
    "access_token": "token"
}

In this way, if try to update the access_token you will not be able because the access_token attribute is part of the key.

If you want to update the access_token you will need to create another table without/or with a different sort key, and use the access_token as atribute.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.