DynamoDB - Key element does not match the schema

前端 未结 4 1996
予麋鹿
予麋鹿 2021-02-05 01:35

I\'m trying to update an Item in my Dynamodb Table +Users+. I have tried many different ways but I always received the same error message:

The provided k

相关标签:
4条回答
  • 2021-02-05 01:38

    For others who have faced the same challenge and the issue is not fixed by above answers, it is always better to double check the data type of the value being updated, in my case the primary key was expecting a Number and I was trying to update with a string. Silly me

    0 讨论(0)
  • 2021-02-05 01:52

    I was doing BatchGetItem, then streamed it to BatchWriteItem (Delete). DeleteItem didn't like it got all attributes from the object instead of only partition and sort key.

    Gathering all answers:

    • mismatch in an attribute name
    • mismatch in attribute type
    • half key provided
    • unnecessary additional keys
    0 讨论(0)
  • 2021-02-05 01:53

    You are only providing half of your primary key. Your primary key is a combination of the partition key and range key. You need to include the range key in your Key attribute in the update parameters.

    0 讨论(0)
  • 2021-02-05 01:55

    My checklist when facing this issue:

    1. Check that the name and type of your key correspond to what you have in the database.
    2. Use corresponding attributes to make it explicit. E.g. use @DynamoDBHashKey(attributeName = "userId") in Java to indicate the partition key named userId.
    3. Ensure that only one field or getter marked as partition key in your class.

    Please, add more if you know in the comments.

    0 讨论(0)
提交回复
热议问题