fix(dynamodb): accept grouped OR and NOT in PartiQL UPDATE and DELETE (#9332)

#9305 ran the full expression check on every write condition in
DynamoDbService.evaluateCondition, and PartiQL UPDATE and DELETE pass a
condition built from the WHERE clause there, with a grouped OR or NOT in a
second pair of parentheses, so the redundant parentheses check refused
statements DynamoDB accepts. The check now runs where the typed backend takes
a put, update or delete, so Step Functions tasks still refuse an unknown
function, and PartiQL writes behave as they did before #9305.
This commit is contained in:
TATSUNO “Taz” Yasuhiro authored and GitHub committed 2026-11-24 06:45:56 -04:00
1 parent 0acd3307b3
commit ee51e7b993
5 files changed
+64 -14

No files matched your search

@@ -3748,6 +3748,11 @@ public class DynamoDbService {
// --- Condition expression evaluation ---
public void validateConditionExpression(String conditionExpression, JsonNode exprAttrNames,
JsonNode exprAttrValues) {
validateExpression(conditionExpression, "ConditionExpression", exprAttrNames, exprAttrValues);
}
public void validateFilterExpression(String filterExpression, JsonNode exprAttrNames, JsonNode exprAttrValues) {
validateExpression(filterExpression, "FilterExpression", exprAttrNames, exprAttrValues);
}
@@ -3760,7 +3765,7 @@ public class DynamoDbService {
private void evaluateCondition(JsonNode existingItem, String conditionExpression,
JsonNode exprAttrNames, JsonNode exprAttrValues, String returnValuesOnConditionCheckFailure) {
validateExpression(conditionExpression, "ConditionExpression", exprAttrNames, exprAttrValues);
DynamoDbReservedWords.check(conditionExpression, "ConditionExpression");
if (!matchesFilterExpression(existingItem, conditionExpression, exprAttrNames, exprAttrValues)) {
if ("ALL_OLD".equals(returnValuesOnConditionCheckFailure)){
throw new ConditionalCheckFailedException(existingItem);
@@ -119,6 +119,8 @@ public class NativeDynamoDbBackend implements DynamoDbBackend {
@Override
public void putItem(Scope scope, String tableName, JsonNode item, String conditionExpression,
JsonNode expressionAttributeNames, JsonNode expressionAttributeValues) {
dynamoDbService.validateConditionExpression(conditionExpression, expressionAttributeNames,
expressionAttributeValues);
RequestScopes.runAs(scope.accountId(), () -> dynamoDbService.putItem(tableName,
DynamoDbMapOrder.sortedItem(item), conditionExpression,
expressionAttributeNames, expressionAttributeValues, scope.region(), "NONE"));
@@ -132,6 +134,8 @@ public class NativeDynamoDbBackend implements DynamoDbBackend {
@Override
public void deleteItem(Scope scope, String tableName, JsonNode key, String conditionExpression,
JsonNode expressionAttributeNames, JsonNode expressionAttributeValues) {
dynamoDbService.validateConditionExpression(conditionExpression, expressionAttributeNames,
expressionAttributeValues);
RequestScopes.runAs(scope.accountId(), () -> dynamoDbService.deleteItem(tableName, key, conditionExpression,
expressionAttributeNames, expressionAttributeValues, scope.region(), "NONE"));
}
@@ -140,6 +144,8 @@ public class NativeDynamoDbBackend implements DynamoDbBackend {
public JsonNode updateItem(Scope scope, String tableName, JsonNode key, JsonNode attributeUpdates,
String updateExpression, JsonNode expressionAttributeNames,
JsonNode expressionAttributeValues, String returnValues, String conditionExpression) {
dynamoDbService.validateConditionExpression(conditionExpression, expressionAttributeNames,
expressionAttributeValues);
DynamoDbService.UpdateResult result = RequestScopes.callAs(scope.accountId(), () ->
dynamoDbService.updateItem(tableName, key,
DynamoDbMapOrder.sortedAttributeUpdates(attributeUpdates), updateExpression,