Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NPE when walking a missing node that will have missing properties #1152

Merged
merged 2 commits into from
Feb 7, 2025

Conversation

justin-tay
Copy link
Contributor

Closes #1151

Fixes the NPE by having TypeFactory.getValueNodeType((JsonNode node, SchemaValidatorsConfig config) handle the case where a null was passed in as the node.

I had considered if it should be ensured that the node inputs should always be non null and always replace null by MissingNode instead. For instance having PropertiesValidator set the input as MissingNode instead of null. But since JsonNode.get(String fieldName) returns null for missing nodes I wasn't sure it would be appropriate.

@codecov-commenter
Copy link

codecov-commenter commented Feb 7, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.13%. Comparing base (48ca3c2) to head (5ae2fff).
Report is 78 commits behind head on master.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1152      +/-   ##
============================================
- Coverage     78.90%   78.13%   -0.77%     
- Complexity     1965     2066     +101     
============================================
  Files           172      201      +29     
  Lines          6352     6861     +509     
  Branches       1255     1255              
============================================
+ Hits           5012     5361     +349     
- Misses          867     1033     +166     
+ Partials        473      467       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jkosternl jkosternl left a comment

Choose a reason for hiding this comment

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

Just 2 minor remarks, to take into consideration. Good job!

@stevehu stevehu merged commit da3865c into networknt:master Feb 7, 2025
4 checks passed
@stevehu
Copy link
Contributor

stevehu commented Feb 10, 2025

@justin-tay The latest commit is not included in the previous PR which is merged so quickly. Could you please submit another PR to include the test case? Thanks.

@justin-tay
Copy link
Contributor Author

@stevehu It looks like the latest commit to add the assertDoesNotThrow was included in the merged commit da3865c so there's nothing more. Thanks!

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.

NPE during JSON schema walk with validation
4 participants