amazon-dynamodbdynamodb-queriesamazon-dynamodb-index

Do I need to include Key attributes of all Global Secondary Indices when doing UpdateItem in DynamoDB?


I have a table with these columns:

and two secondary indices attached to it. 1 index is using Key field email and another - order_id.

When I do UpdateItem for the table, where I change only note, updated_at (and using key subscription_id), I get an error returned The AttributeValue for a key attribute cannot contain an empty string value.". However, I do not use any attribute which is a Key for a GSI.

Does that mean that after I have any GSI attached to the table, I need to always include all of their Key attributes in the UpdateItem calls?


Solution

  • Actually the problem was that item, which I was updating, had a property, which was a GSI Key, set to an empty string. I understood the root cause from this answer.

    To fix the problem I had to update my database to remove all non-conformant fields.