From 6fb05d64539a10a2d769bb3d91dd226d50bf9278 Mon Sep 17 00:00:00 2001 From: Avi Slavkin <80623842+avislav@users.noreply.github.com> Date: Wed, 23 Jun 2021 18:53:05 +0300 Subject: [PATCH] Update __init__.py (#4024) In case of DELETE action we don't pass the value if we want to remove the attribute. There are more cases but it's for you to handle. --- moto/dynamodb2/models/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/moto/dynamodb2/models/__init__.py b/moto/dynamodb2/models/__init__.py index 06bd3e85..373f932d 100644 --- a/moto/dynamodb2/models/__init__.py +++ b/moto/dynamodb2/models/__init__.py @@ -120,6 +120,8 @@ class Item(BaseModel): def validate_no_empty_key_values(self, attribute_updates, key_attributes): for attribute_name, update_action in attribute_updates.items(): action = update_action.get("Action") or "PUT" # PUT is default + if action == "DELETE": + continue new_value = next(iter(update_action["Value"].values())) if action == "PUT" and new_value == "" and attribute_name in key_attributes: raise EmptyKeyAttributeException