AffectedNodeDeserializer NPE on missing LedgerEntryType (Issue #750)#797
Open
cybele-ripple wants to merge 5 commits into
Open
AffectedNodeDeserializer NPE on missing LedgerEntryType (Issue #750)#797cybele-ripple wants to merge 5 commits into
cybele-ripple wants to merge 5 commits into
Conversation
Guard against null LedgerEntryType in AffectedNodeDeserializer by throwing MismatchedInputException instead of a NullPointerException when the field is absent from a CreatedNode, ModifiedNode, or DeletedNode payload.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #797 +/- ##
=========================================
Coverage 93.51% 93.51%
- Complexity 2606 2608 +2
=========================================
Files 486 486
Lines 6580 6582 +2
Branches 566 567 +1
=========================================
+ Hits 6153 6155 +2
Misses 270 270
Partials 157 157 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…serializer Covers the isNull() branch of the null-check condition to reach 100% patch coverage.
Collaborator
Author
|
/ai-review |
sappenin
requested changes
Jun 12, 2026
| @@ -56,9 +57,13 @@ public AffectedNode deserialize(JsonParser jsonParser, DeserializationContext ct | |||
| Map.Entry<String, JsonNode> nodeFieldAndValue = jsonNode.fields().next(); | |||
Collaborator
There was a problem hiding this comment.
This PR is heading in the right direction, but it has me thinking of two things:
- If we keep this PR, we should be more agressive about checking for potentially null values (e.g.,
odeFieldAndValue.getValue().get("LedgerEntryType");) - If we do encounter a null value anywhere, it seems better to just log this as a warning and continue/skip the invalid input. PR Alternate approach to #797: warn-and-skip instead of throw on null input (Fixed #750) #807 is my attempt to implement that strategy.
@cybele-ripple @Patel-Raj11 Take a look and both, and let me know which one you prefer. Currently, I think #807 is a better approach, but am open to hearing alternate opinions.
| MetaLedgerEntryType ledgerEntryType = MetaLedgerEntryType.of( | ||
| nodeFieldAndValue.getValue().get("LedgerEntryType").asText() | ||
| ); | ||
| JsonNode ledgerEntryTypeNode = nodeFieldAndValue.getValue().get("LedgerEntryType"); |
Collaborator
There was a problem hiding this comment.
We should guard against a null nodeFieldAndValue.getValue()
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.
Updated exception use case so that
MismatchedInputExceptionis thrown instead of aNullPointerExceptionwhenLedgerEntryTypeis absent from aCreatedNode,ModifiedNode, orDeletedNodepayload. There was previously no associated unit tests forAffectedNodeDeserializerTest.javasoAffectedNodeDeserializer.javawas added.