fix(dynamodb): use the older check order and wording for an UpdateItem without Key or nested too deep (#7608)

This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-11-05 11:56:52 -04:00
1 parent bc9f7b518d
commit ddfc63f6b6
3 files changed
+119 -25

No files matched your search

@@ -5889,8 +5889,12 @@ given()
PutItem | {"TableName": "Missing", "Item": {"pk": {"S": "a"}}, "Expected": {"a": {"Value": "DEEP"}, "b": {"Exists": false}}, "ConditionalOperator": "XOR"} | 1 validation error detected: Value 'XOR' at 'conditionalOperator' failed to satisfy constraint: Member must satisfy enum value set: [OR, AND]
DeleteItem | {"TableName": "Missing", "Key": {"pk": "DEEP"}, "ReturnValues": "UPDATED_NEW"} | ReturnValues can only be ALL_OLD or NONE
PutItem | {"TableName": "Missing", "Item": {"pk": {"S": "a"}, "d": {"S": "x", "Foo": "y"}}, "ReturnValues": "BOGUS"} | 1 validation error detected: Value 'BOGUS' at 'returnValues' failed to satisfy constraint: Member must satisfy enum value set: [ALL_NEW, UPDATED_OLD, ALL_OLD, NONE, UPDATED_NEW]
UpdateItem | {"TableName": "", "UpdateExpression": "SET a = :a", "ExpressionAttributeValues": {":a": {"S": "x"}}, "ReturnConsumedCapacity": "BOGUS", "ReturnValues": "BOGUS"} | 4 validation errors detected: Value 'BOGUS' at 'returnConsumedCapacity' failed to satisfy constraint: Member must satisfy enum value set: [INDEXES, TOTAL, NONE]; Value '' at 'tableName' failed to satisfy constraint: Member must have length greater than or equal to 1; Value 'BOGUS' at 'returnValues' failed to satisfy constraint: Member must satisfy enum value set: [ALL_NEW, UPDATED_OLD, ALL_OLD, NONE, UPDATED_NEW]; Value null at 'key' failed to satisfy constraint: Member must not be null
UpdateItem | {"TableName": "Missing", "AttributeUpdates": {"a": {"Action": "BOGUS", "Value": {"S": "x"}}}} | 2 validation errors detected: Value 'BOGUS' at 'attributeUpdates.a.member.action' failed to satisfy constraint: Member must satisfy enum value set: [ADD, DELETE, PUT]; Value null at 'key' failed to satisfy constraint: Member must not be null
UpdateItem | {"TableName": "Missing", "Key": {"pk": {"S": "a"}}, "AttributeUpdates": {"x": {"Action": "PUT", "Value": {"S": "1"}}}, "Expected": {"a": {"Value": "DEEP"}, "b": {"Exists": false}}, "ConditionalOperator": "XOR"} | 1 validation error detected: Value 'XOR' at 'conditionalOperator' failed to satisfy constraint: Member must satisfy enum value set: [OR, AND]
UpdateItem | {"TableName": "Missing", "Key": {"pk": {"S": "a"}}, "UpdateExpression": "SET t = :t", "ConditionExpression": "d = :deep", "ExpressionAttributeValues": {":t": {"S": "y"}, ":deep": "DEEP"}} | ExpressionAttributeValues contains invalid value: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit for key :deep
""")
void putAndDeleteItemGetTheOlderChecksWhenTheNewerValidatorGivesUp(String operation, String body,
void itemWritesGetTheOlderChecksWhenTheNewerValidatorGivesUp(String operation, String body,
String message) {
String deep = "{\"M\": {\"n\": ".repeat(63) + "{\"S\": \"leaf\"}" + "}}".repeat(63);
given()
@@ -2415,8 +2415,24 @@ class NativeDynamoDbJsonHandlerTest {
PutItem | 0 | {"TableName":"Missing","Item":{"pk":{"S":"a"},"d":{"L":[{"S":"x","Foo":"y"}]}},"ReturnValues":"BOGUS"} | 1 validation error detected: Value 'BOGUS' at 'returnValues' failed to satisfy constraint: Member must satisfy enum value set: [ALL_NEW, UPDATED_OLD, ALL_OLD, NONE, UPDATED_NEW]
DeleteItem | 0 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"Expected":{"d":{"ComparisonOperator":"IN","AttributeValueList":[{"S":"x","Foo":"y"}]}},"ReturnValues":"BOGUS"} | 1 validation error detected: Value 'BOGUS' at 'returnValues' failed to satisfy constraint: Member must satisfy enum value set: [ALL_NEW, UPDATED_OLD, ALL_OLD, NONE, UPDATED_NEW]
DeleteItem | 63 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"Expected":{"d":{"Value":{"S":"x"},"Foo":"DEEP"}},"ReturnValues":"BOGUS"} | 1 validation error detected: Failed to satisfy constraint: Member must satisfy enum value set: [ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATE_NEW, NONE]
PutItem | 63 | {"TableName":"Missing","Item":{"pk":"DEEP","n":{"N":"x"}}} | The parameter cannot be converted to a numeric value: x
DeleteItem | 63 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"ConditionExpression":"#d = :a OR #d = :b","ExpressionAttributeNames":{"#d":"d"},"ExpressionAttributeValues":{":a":"DEEP",":b":"DEEP"}} | ExpressionAttributeValues contains invalid value: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit for key :b
UpdateItem | 0 | {"TableName":"","AttributeUpdates":{"b":{"Action":"BOGUS2"},"a":{"Action":"BOGUS"}},"Expected":{"k":{"ComparisonOperator":"BOGUS2"},"i":{"ComparisonOperator":"BOGUS"}},"ReturnValues":"BOGUS","ConditionalOperator":"XOR","ReturnValuesOnConditionCheckFailure":"BOGUS","ReturnConsumedCapacity":"BOGUS","ReturnItemCollectionMetrics":"BOGUS"} | 10 validation errors detected: Value 'BOGUS' at 'expected.i.member.comparisonOperator' failed to satisfy constraint: Member must satisfy enum value set: [IN, NULL, BETWEEN, LT, NOT_CONTAINS, EQ, GT, NOT_NULL, NE, LE, BEGINS_WITH, GE, CONTAINS]; Value 'BOGUS2' at 'expected.k.member.comparisonOperator' failed to satisfy constraint: Member must satisfy enum value set: [IN, NULL, BETWEEN, LT, NOT_CONTAINS, EQ, GT, NOT_NULL, NE, LE, BEGINS_WITH, GE, CONTAINS]; Value 'BOGUS' at 'returnConsumedCapacity' failed to satisfy constraint: Member must satisfy enum value set: [INDEXES, TOTAL, NONE]; Value '' at 'tableName' failed to satisfy constraint: Member must have length greater than or equal to 1; Value 'BOGUS' at 'returnValues' failed to satisfy constraint: Member must satisfy enum value set: [ALL_NEW, UPDATED_OLD, ALL_OLD, NONE, UPDATED_NEW]; Value 'XOR' at 'conditionalOperator' failed to satisfy constraint: Member must satisfy enum value set: [OR, AND]; Value 'BOGUS' at 'returnValuesOnConditionCheckFailure' failed to satisfy constraint: Member must satisfy enum value set: [ALL_OLD, NONE]; Value 'BOGUS' at 'attributeUpdates.a.member.action' failed to satisfy constraint: Member must satisfy enum value set: [ADD, DELETE, PUT]; Value 'BOGUS2' at 'attributeUpdates.b.member.action' failed to satisfy constraint: Member must satisfy enum value set: [ADD, DELETE, PUT]; Value 'BOGUS' at 'returnItemCollectionMetrics' failed to satisfy constraint: Member must satisfy enum value set: [SIZE, NONE]
UpdateItem | 0 | {"AttributeUpdates":{"a":{"Action":"PUT","Value":{"S":"x"}}}} | 2 validation errors detected: Value null at 'tableName' failed to satisfy constraint: Member must not be null; Value null at 'key' failed to satisfy constraint: Member must not be null
UpdateItem | 62 | {"TableName":"a!","Key":{"pk":{"S":"a"}},"AttributeUpdates":{"a":{"Action":"PUT","Value":"DEEP"}}} | 2 validation errors detected: Value 'a!' at 'tableName' failed to satisfy constraint: Member must have length greater than or equal to 3; Value 'a!' at 'tableName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z0-9_.-]+
UpdateItem | 63 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"UpdateExpression":"SET a = :a","ConditionExpression":"a = = b","ExpressionAttributeValues":{":a":"DEEP"},"AttributeUpdates":{"b":{"Action":"PUT","Value":{"S":"1"}}},"Expected":{"b":{"Exists":false}},"ConditionalOperator":"AND"} | Can not use both expression and non-expression parameters in the same request: Non-expression parameters: {AttributeUpdates, Expected, ConditionalOperator} Expression parameters: {UpdateExpression, ConditionExpression}
UpdateItem | 62 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"AttributeUpdates":{"a":{"Action":"PUT","Value":"DEEP"}},"ExpressionAttributeValues":{":v":{"S":"v"}},"ExpressionAttributeNames":{"#n":"n"}} | ExpressionAttributeNames can only be specified when using expressions
UpdateItem | 62 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"AttributeUpdates":{"a":{"Action":"PUT","Value":"DEEP"}},"ExpressionAttributeValues":{":v":{"S":"v"}}} | ExpressionAttributeValues can only be specified when using expressions: UpdateExpression and ConditionExpression are null
UpdateItem | 33 | {"TableName":"Missing","Key":{"pk":"DEEP","n":{"N":"x"}},"UpdateExpression":"SET a = :a","ExpressionAttributeValues":{":a":{"S":"x","Foo":"y"}}} | The parameter cannot be converted to a numeric value: x
UpdateItem | 0 | {"TableName":"Missing","Key":{"pk":{"S":"a","Foo":"y"},"z":{"N":"x"},"m":{"M":{"":{"S":"x"}}}},"AttributeUpdates":{"a":{"Action":"PUT","Value":{"N":"y"}}}} | Empty attribute name
UpdateItem | 0 | {"TableName":"Missing","Key":{"pk":{"S":"a","Foo":"y"},"n":{"N":"x"}},"AttributeUpdates":{"":{"Action":"PUT","Value":{"S":"x"}},"a":{"Action":"PUT","Value":{"S":"x"}}}} | The parameter cannot be converted to a numeric value: x
UpdateItem | 0 | {"TableName":"Missing","Key":{"pk":{"S":"a","Foo":"y"}},"AttributeUpdates":{"z":{"Action":"PUT","Value":{"N":"x"}},"m":{"Action":"PUT","Value":{"M":{"":{"S":"x"}}}}}} | Empty attribute name
UpdateItem | 33 | {"TableName":"Missing","Key":{"pk":{"S":"a","Foo":"y"}},"AttributeUpdates":{"m":{"Action":"PUT","Value":"DEEP"},"a":{"Action":"PUT","Value":{"N":"x"}}}} | Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit
UpdateItem | 33 | {"TableName":"Missing","Key":{"pk":{"S":"a","Foo":"y"}},"UpdateExpression":"SET a = :q + :b + :x + :e + :k + :c","ExpressionAttributeValues":{":q":{"N":"x"},":b":{"S":"x"},":x":{"S":"x"},":e":{"S":"x"},":k":"DEEP",":c":{"S":"x"}}} | ExpressionAttributeValues contains invalid value: Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit for key :k
UpdateItem | 62 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"AttributeUpdates":{"a":{"Action":"PUT","Value":{"S":"x"}}},"Expected":{"e":{"Value":"DEEP"}}} | Nesting Levels have exceeded supported limits: Attributes in the item have nested levels beyond supported limit
UpdateItem | 0 | {"TableName":"Missing","Key":{"pk":{"S":"a"}},"AttributeUpdates":{"a":{"Action":"PUT","Value":{"S":"x","Foo":"y"}}},"ReturnValues":"BOGUS"} | 1 validation error detected: Value 'BOGUS' at 'returnValues' failed to satisfy constraint: Member must satisfy enum value set: [ALL_NEW, UPDATED_OLD, ALL_OLD, NONE, UPDATED_NEW]
""")
void theOlderValidatorChecksAPutOrDeleteTheNewerOneGivesUpOn(String operation, int levels,
void theOlderValidatorChecksAnItemWriteTheNewerOneGivesUpOn(String operation, int levels,
String request, String message) throws Exception {
JsonNode body = mapper.readTree(request.replace("\"DEEP\"", mapper.writeValueAsString(nestedMaps(levels))));
@@ -2432,6 +2448,7 @@ class NativeDynamoDbJsonHandlerTest {
61 | {"TransactItems":[{"Put":{"TableName":"","Item":{}}}]} | 1 validation error detected: Value '' at 'transactItems.1.member.put.tableName' failed to satisfy constraint: Member must have length greater than or equal to 1
60 | {"TransactItems":[{"Put":{"TableName":"","Item":{}}}]} | 1 validation error detected: Value at 'TransactItems.0.member.Put.TableName' failed to satisfy constraint: Member must have length greater than or equal to 1
60 | {"TransactItems":[{}],"ReturnConsumedCapacity":"BOGUS"} | 2 validation errors detected: Value '' at 'transactItems' failed to satisfy constraint: TransactWriteRequest should contain Delete or Put or Update or ConditionCheck; Value 'BOGUS' at 'returnConsumedCapacity' failed to satisfy constraint: Member must satisfy enum value set: [INDEXES, TOTAL, NONE]
63 | {"TransactItems":[{"ConditionCheck":{"TableName":"Missing","Key":{"pk":{"S":"a"}},"ConditionExpression":"a IN (:q, :b, :x, :e, :k, :c)","ExpressionAttributeValues":{":q":{"N":"x"},":b":{"S":"x"},":x":{"S":"x"},":e":{"S":"x"},":k":{"N":"y"},":c":{"S":"x"}}}}]} | ExpressionAttributeValues contains invalid value: The parameter cannot be converted to a numeric value: y for key :k
""")
void aTransactionNestedTooDeepForTheNewerValidatorIsCheckedByTheOlderOne(int levels, String request,
String message) throws Exception {