Reputation: 2712
I have a string field, "title". I am trying to update it with the update expression with
persontable.update_item(Key={'person_id':person_id}, UpdateExpression="SET title = UPDATED")
and I get
An error occurred (ValidationException) when calling the UpdateItem operation: The provided expression refers to an attribute that does not exist in the item
I can see the attribute "title" for that person in the AWS console. What gives?
Upvotes: 8
Views: 21610
Reputation: 335
Check whether item has created properly before updating.
When the Table is not in "ACTIVE" state, if you try to put_item - it will not be created and next when when you try to update the same item which is not created. This error will occur.
Execute the put_item when the state is in "ACTIVE" state and then update item properly. You will not get this error.
Upvotes: -1
Reputation: 166
Don't plug the value into the expression directly. Rather use ExpressionAttributeValues -- see boto3 guide
persontable.update_item(Key={'person_id':person_id},
UpdateExpression="SET title = :updated",
ExpressionAttributeValues={':updated': 'UPDATED'})
Upvotes: 13