Dynamodb missing error with ADD empty set
This error is caught by aws, but not with moto:
ExpressionAttributeValues contains invalid value: One or more parameter values were invalid: An number set may not be empty for key :deletedConversationIds
It's caused by an update like this:
user_table.update_item(
TableName="Users",
Key={"userId": user_id},
UpdateExpression="ADD stringSet :emptySet",
ExpressionAttributeValues={
":emptySet": empty_set,
},
)
I found another similar issue:
if an ExpressionAttributeValue is defined and not used, it errors in real aws, but not moto:
Value provided in ExpressionAttributeValues unused in expressions: keys: {:variable}
Hi @jasonrdunne, thanks for raising these! I'll open a PR to add validation for the first issue in a second.
Do you have an example for the second issue? The following code does throw an error in Moto:
dynamodb.update_item(
TableName=table_name,
Key={"pk": {"S": "foo"}},
UpdateExpression="ADD stringset :emptySet",
ExpressionAttributeValues={":emptySet": {"SS": ()}, "other": {"S": "data"}},
)
I also ran into a similar issue, analogue to the issue @jasonrdunne described. My update_item call looks like this:
db_response = table.update_item(
Key={
'shortid': tenant_id
},
UpdateExpression="SET spec.#limit = :limit",
ExpressionAttributeNames={
"#count": "count",
"#limit": "limit"
},
ExpressionAttributeValues={
":countChange": 1,
":limit": limit
},
ConditionExpression="attribute_exists(shortid)",
ReturnValues="ALL_NEW"
)
And real AWS throws the error: 'Message': 'Value provided in ExpressionAttributeNames unused in expressions: keys: {#count}', 'Code': 'ValidationException'
while moto does not throw an error
Thanks for letting us know @roehlc - the attached PR will add that validation to Moto.