Throw SerializationException for null values in dense collections#1261
Merged
sugmanue merged 1 commit intoJun 23, 2026
Merged
Conversation
adwsingh
approved these changes
Jun 23, 2026
Both codegen and dynamic schema deserialization paths now reject null values in non-sparse lists and maps with a SerializationException instead of silently skipping or corrupting data.
0dfe0b9 to
e60c2be
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both codegen and dynamic schema deserialization paths now reject null values in non-sparse lists and maps with a SerializationException instead of silently skipping or corrupting data.
What behavior changes?
SerializationException."null", and null in dense maps flowed through unchecked, causing NPE later during serialization. Now throwsSerializationException.Why is this change needed?
A customer reported an NPE in the MCP server path when a response contained null values in a dense map. The null was silently accepted during deserialization, then caused a
NullPointerExceptioninsideContentDocument.serializeContentswhen the result was later accessed viagetMember. The fix fails fast at deserialization time with a clear error message.How was this validated?
SchemaGuidedDocumentBuilderTest): 7 new tests covering dense throw, sparse preserve, validation on setMemberValue, and the customer's nested map NPE scenario.sparse-vs-dense-collections): Verifies generatedSharedSerdeemits the correct throw/preserve logic for dense vs sparse collections.DenseSparseNullTest): 4 tests exercising generated builders at runtime with null values in dense/sparse lists and maps.StringListin the test model marked@sparsesince those tests exercise null-in-list behavior.What should reviewers focus on?
SchemaGuidedDocumentBuilder.java;ListConsumerandMapConsumernull handling (the core fix for dynamic schemas).ListGenerator.java/MapGenerator.java; template changes for codegen (the${^sparse}throw...${/sparse}pattern).PluginTestRunner.java; removeddiscoverModels()to make golden file tests deterministic.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.