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

walk fails with validation and unevaluatedProperties #877

Closed
holgpar opened this issue Oct 16, 2023 · 1 comment · Fixed by #931
Closed

walk fails with validation and unevaluatedProperties #877

holgpar opened this issue Oct 16, 2023 · 1 comment · Fixed by #931

Comments

@holgpar
Copy link
Contributor

holgpar commented Oct 16, 2023

Hi,

I wanted to walk and validate the following schema:

{
  "type": "object",
  "unevaluatedProperties": false
}

like so:

  @Test
  void walkWith__unevaluatedProperties() throws JsonProcessingException {
    JsonSchema test = getJsonSchemaFromClasspath("schemas/unevaluated.json");
    JsonNode probe = mapper.readTree("{}");

    // THIS WORKS
    test.walk(probe, false);
    test.validate(probe);

    // THIS FAILS
    test.walk(probe, true);
  }

However, this fails with an NPE:

java.lang.NullPointerException: Cannot invoke "com.networknt.schema.CollectorContext$Scope.getContainingSchema()" because "parent" is null

	at com.networknt.schema.CollectorContext.enterDynamicScope(CollectorContext.java:85)
	at com.networknt.schema.CollectorContext.enterDynamicScope(CollectorContext.java:74)
	at com.networknt.schema.UnevaluatedPropertiesValidator.validate(UnevaluatedPropertiesValidator.java:83)
	at com.networknt.schema.BaseJsonValidator.walk(BaseJsonValidator.java:200)
	at com.networknt.schema.JsonSchema.lambda$walk$1(JsonSchema.java:544)
	at java.base/java.util.TreeMap.forEach(TreeMap.java:1002)
	at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1505)
	at com.networknt.schema.JsonSchema.walk(JsonSchema.java:531)
	at com.networknt.schema.JsonSchema.walkAtNodeInternal(JsonSchema.java:511)
	at com.networknt.schema.JsonSchema.walk(JsonSchema.java:495)
	at schemas.JSONSchemaTest.walkWith__unevaluatedProperties(JSONSchemaTest.java:144)
@holgpar holgpar changed the title walk failes with validation and unevaluatedProperties walk fails with validation and unevaluatedProperties Oct 16, 2023
@mmorys
Copy link

mmorys commented Jan 5, 2024

Have you had any resolution to this issue? I am experiencing the same :(

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 a pull request may close this issue.

2 participants