Skip to content

AffectedNodeDeserializer NPE on missing LedgerEntryType (Issue #750)#797

Open
cybele-ripple wants to merge 5 commits into
mainfrom
affectednodedeserializerNPE-missing
Open

AffectedNodeDeserializer NPE on missing LedgerEntryType (Issue #750)#797
cybele-ripple wants to merge 5 commits into
mainfrom
affectednodedeserializerNPE-missing

Conversation

@cybele-ripple

Copy link
Copy Markdown
Collaborator

Updated exception use case so that MismatchedInputException is thrown instead of a NullPointerException when LedgerEntryType is absent from a CreatedNode, ModifiedNode, or DeletedNode payload. There was previously no associated unit tests for AffectedNodeDeserializerTest.java so AffectedNodeDeserializer.java was added.

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

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.51%. Comparing base (4871032) to head (a039d78).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…serializer

Covers the isNull() branch of the null-check condition to reach 100% patch coverage.
@cybele-ripple

Copy link
Copy Markdown
Collaborator Author

/ai-review

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

@@ -56,9 +57,13 @@ public AffectedNode deserialize(JsonParser jsonParser, DeserializationContext ct
Map.Entry<String, JsonNode> nodeFieldAndValue = jsonNode.fields().next();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is heading in the right direction, but it has me thinking of two things:

  1. If we keep this PR, we should be more agressive about checking for potentially null values (e.g., odeFieldAndValue.getValue().get("LedgerEntryType");)
  2. 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");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should guard against a null nodeFieldAndValue.getValue()

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants