What happened?
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 selected with a size check:
} else if (value.ss() != null && value.ss().size() > 0) { // correct: DynamoDB rejects empty sets
...
} 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
} else if (value.nul() != null) {
...
} else {
throw new CoderException("Unknown Type");
}
For an empty L, l() is non-null and size() is 0, so the guard fails; m() and nul() do not match either, and it falls through to the terminal else.
The blast radius is the whole item, not one attribute. MAP_ATTRIBUTE_CODER re-enters this coder for every child, so a single empty list nested anywhere inside an item makes that item unencodable:
Map<String, AttributeValue> item = new HashMap<>();
item.put("name", AttributeValue.builder().s("widget").build());
item.put("tags", AttributeValue.builder().l(new ArrayList<>()).build());
AttributeValueCoder.of().encode(AttributeValue.builder().m(item).build(), out);
// CoderException: Unknown Type
Empty L and M are valid DynamoDB attribute values and the service returns them, unlike the SS/NS/BS set types where the size() > 0 guard is legitimate — DynamoDB rejects empty sets.
The decode side already copes: case l: and case m: delegate to ListCoder/MapCoder, which round-trip empties fine. Only encode rejects them.
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components
What happened?
AttributeValueCoder.encodecannot encode a DynamoDB attribute whose value is an empty list or an empty map — it throwsCoderException("Unknown Type").The L and M branches are selected with a size check:
For an empty
L,l()is non-null andsize()is 0, so the guard fails;m()andnul()do not match either, and it falls through to the terminalelse.The blast radius is the whole item, not one attribute.
MAP_ATTRIBUTE_CODERre-enters this coder for every child, so a single empty list nested anywhere inside an item makes that item unencodable:Empty
LandMare valid DynamoDB attribute values and the service returns them, unlike theSS/NS/BSset types where thesize() > 0guard is legitimate — DynamoDB rejects empty sets.The
decodeside already copes:case l:andcase m:delegate toListCoder/MapCoder, which round-trip empties fine. Onlyencoderejects them.Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Issue Components