fix(dynamodb): throw ValidationException when list_append operand is not a list type (#1702)

* fix(dynamodb): throw ValidationException when list_append operand is not a list type

list_append silently no-oped when either operand resolved to a non-list
attribute (e.g. NULL type), returning HTTP 200 with the item unchanged.
AWS returns a 400 ValidationException in this case.

* test(dynamodb): add integration test for list_append against missing attribute
This commit is contained in:
Prabu Dzaky authored and GitHub committed 2026-07-22 08:35:07 -04:00
1 parent b245632a2e
commit 2a9ab4598f
3 files changed
+188 -9

No files matched your search

@@ -1586,16 +1586,22 @@ public class DynamoDbService {
String arg2 = inner.substring(commaPos + 1).trim();
JsonNode list1 = evaluateSetExpr(snapshot, arg1, exprAttrNames, exprAttrValues);
JsonNode list2 = evaluateSetExpr(snapshot, arg2, exprAttrNames, exprAttrValues);
if (list1 != null && list2 != null && list1.has("L") && list2.has("L")) {
com.fasterxml.jackson.databind.node.ArrayNode merged =
com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.arrayNode();
list1.get("L").forEach(merged::add);
list2.get("L").forEach(merged::add);
com.fasterxml.jackson.databind.node.ObjectNode result =
com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
result.set("L", merged);
item.set(attrName, result);
if (list1 == null || list2 == null) {
throw new AwsException("ValidationException",
"The provided expression refers to an attribute that does not exist in the item", 400);
}
if (!list1.has("L") || !list2.has("L")) {
throw new AwsException("ValidationException",
"An operand in the update expression has an incorrect data type", 400);
}
com.fasterxml.jackson.databind.node.ArrayNode merged =
com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.arrayNode();
list1.get("L").forEach(merged::add);
list2.get("L").forEach(merged::add);
com.fasterxml.jackson.databind.node.ObjectNode result =
com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
result.set("L", merged);
item.set(attrName, result);
}
}
} else if (valuePart.startsWith(":") && exprAttrValues != null) {