1

I am trying to update an item from my DynamoDb table from a AWS Lambda function and I am getting the following error:

"errorMessage": "An error occurred (ValidationException) when calling the UpdateItem operation: The provided key element does not match the schema",

I have not defined a sort key when defining my table, and my partition key is named 'pipeId', and I have used the following code:

dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('mytable')

response = table.update_item(
    Key={
        'pipeId': pipe_id
        },
    UpdateExpression="set hookId = :r",
    ExpressionAttributeValues={
            ':r': hook_id
        },
    ReturnValues="UPDATED_NEW"
)

Isn't possible to get or update an item without previously setting a sort key ? or am I doing something wrong here ?

2
  • 1
    I don't see anything about sort key in the error message, so not sure why you are focusing on that. It is saying that pipeId is not actually the primary key of your table. Are you sure it's not PipeID or pipe_id or something? Commented Jan 8, 2019 at 19:28
  • I was focusing on that because I saw many other topics pointing that this error was because they were providing an incomplete key; And yes, I am using the right table name. @MarkB thank you Commented Jan 9, 2019 at 10:54

1 Answer 1

2

I have found the solution.

The problem was that my primary key is defined as number and I was inserting it as String, like "3219"; but it doesn't convert automatically.

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

1 Comment

Your Solution woks for me, Thanks for question here

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.