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

Since 1.3.0: IllegalArgumentException instead of JsonSchemaException #935

Closed
itineric opened this issue Jan 29, 2024 · 1 comment · Fixed by #942
Closed

Since 1.3.0: IllegalArgumentException instead of JsonSchemaException #935

itineric opened this issue Jan 29, 2024 · 1 comment · Fixed by #942

Comments

@itineric
Copy link

When passing a bad $schema value, we now get an IllegalArgumentException, it should be a JsonSchemaException as it was before version 1.3.0.

Passing "$schema": "0" gives us

java.lang.IllegalArgumentException: URI is not absolute
	at java.base/java.net.URL.fromURI(URL.java:721) ~[na:na]
	at java.base/java.net.URI.toURL(URI.java:1139) ~[na:na]
	at com.networknt.schema.resource.UriSchemaLoader.lambda$getSchema$0(UriSchemaLoader.java:35) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.getMappedSchema(JsonSchemaFactory.java:479) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.lambda$getSchema$3(JsonSchemaFactory.java:454) ~[json-schema-validator.jar:na]
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) ~[na:na]
	at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:453) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.loadMetaSchema(JsonSchemaFactory.java:359) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.lambda$getMetaSchema$2(JsonSchemaFactory.java:354) ~[json-schema-validator.jar:na]
	at java.base/java.util.Optional.orElseGet(Optional.java:364) ~[na:na]
	at com.networknt.schema.JsonSchemaFactory.getMetaSchema(JsonSchemaFactory.java:352) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.lambda$getMetaSchemaOrDefault$1(JsonSchemaFactory.java:344) ~[json-schema-validator.jar:na]
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708) ~[na:na]
	at com.networknt.schema.JsonSchemaFactory.getMetaSchemaOrDefault(JsonSchemaFactory.java:344) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.createValidationContext(JsonSchemaFactory.java:326) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:257) ~[json-schema-validator.jar:na]
	at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:608) ~[json-schema-validator.jar:na]
@justin-tay
Copy link
Contributor

This is because 1.3.0 included support for loading custom meta schemas. This will be fixed to throw the appropriate exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants