From 1b2f514673f6fddf1b7eedf10c033881643851e2 Mon Sep 17 00:00:00 2001 From: water <672684719@qq.com> Date: Wed, 12 Aug 2026 14:22:29 +0800 Subject: [PATCH] fix: allow empty DynamoDB list and map in AttributeValueCoder DynamoDB allows empty L (list) and M (map) attribute values, but AttributeValueCoder.encode rejects them because the `size() > 0` guard on these branches causes them to fall through to the terminal else. Remove the `size() > 0` guard for L and M branches. The decode side already handles empty lists and maps correctly. Fixes #39730 --- .../apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java b/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java index 79d480e5ef0b..059167d40a0c 100644 --- a/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java +++ b/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/dynamodb/AttributeValueCoder.java @@ -89,10 +89,10 @@ public void encode(AttributeValue value, OutputStream outStream) throws IOExcept } else if (value.bs() != null && value.bs().size() > 0) { StringUtf8Coder.of().encode(AttributeValueType.bs.toString(), outStream); LIST_BYTE_CODER.encode(convertToListByteArray(value.bs()), outStream); - } else if (value.l() != null && value.l().size() > 0) { + } else if (value.l() != null) { StringUtf8Coder.of().encode(AttributeValueType.l.toString(), outStream); LIST_ATTRIBUTE_CODER.encode(value.l(), outStream); - } else if (value.m() != null && value.m().size() > 0) { + } else if (value.m() != null) { StringUtf8Coder.of().encode(AttributeValueType.m.toString(), outStream); MAP_ATTRIBUTE_CODER.encode(value.m(), outStream); } else if (value.nul() != null) {