Skip to content

fix: allow empty DynamoDB list and map in AttributeValueCoder - #39734

Open
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix/dynamodb-empty-list-map-coder
Open

fix: allow empty DynamoDB list and map in AttributeValueCoder#39734
waterWang wants to merge 1 commit into
apache:masterfrom
waterWang:fix/dynamodb-empty-list-map-coder

Conversation

@waterWang

Copy link
Copy Markdown

Problem

AttributeValueCoder.encode cannot encode a DynamoDB attribute whose value is an empty list or an empty map — it throws CoderException("Unknown Type").

The L and M branches are guarded with size() > 0:

} else if (value.l() != null && value.l().size() > 0) {     // wrong: DynamoDB allows an empty L
} else if (value.m() != null && value.m().size() > 0) {     // wrong: DynamoDB allows an empty M

Fix

Remove the size() > 0 guard for L and M branches. The decode side already handles empty lists and maps correctly via ListCoder/MapCoder — only encode rejects them.

Blast radius

A single empty list nested anywhere inside an item makes the whole item unencodable, because MAP_ATTRIBUTE_CODER re-enters this coder for every child.

Fixes #39730

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 apache#39730
@github-actions

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: DynamoDB AttributeValueCoder cannot encode an empty list or empty map attribute

1 participant