Only raise EmptyKeyAttributeException when the value node is empty (#4014)

This fixes a bug where all updates to keys (including GSIs) would raise
EmptyKeyAttributeException, even when the new value was not an empty string.
This commit is contained in:
Thomas Ross 2021-06-17 07:19:47 -04:00 committed by GitHub
commit 67ae84e2c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View file

@ -332,7 +332,11 @@ class EmptyStringKeyValueValidator(DepthFirstTraverser):
assert len(node.children) == 2
key = node.children[0].children[0].children[0]
val_node = node.children[1].children[0]
if val_node.type in ["S", "B"] and key in self.key_attributes:
if (
not val_node.value
and val_node.type in ["S", "B"]
and key in self.key_attributes
):
raise EmptyKeyAttributeException
return node