NullPointerException on visitSchemaOnAdditionalItems with special types
See original GitHub issueHello, I discovered a strange case when I tried to validate my inputs to Google Json Schema for VOD Contents : You can find it here : https://developers.google.com/actions/media/tools/schema_vod.json Here is the problem. In this schema, we have an additional item defined as it :
"@context": {
"oneOf": [
{
"$ref": "#/definitions/generics/string"
},
{
"type": "array",
"minItems": 2,
"contains": {
"enum": [
"http://schema.org/",
"http://schema.org"
]
},
"additionalItems": {
"type": "object",
"properties": {
"@language": {
"type": "string",
"minLength": 2
}
},
"required": [
"@language"
]
}
}
],
"$id": "#/definitions/generics/@context"
},
so it means we can output something like this in each dataFeedElement
object:
"@context": [
"http://schema.org",
{
"@language": "fr-FR"
}],
This one works perfectly on google online validation (https://actions.google.com/tools/feed-validator/u/0/) and with Ajv lib for Node.Js : https://github.com/ajv-validator/ajv
However, here it crashes :
[info] - should generate export file *** FAILED *** (2 seconds, 501 milliseconds) [info] java.lang.NullPointerException: [info] at org.everit.json.schema.ArraySchemaValidatingVisitor.visitSchemaOfAdditionalItems(ArraySchemaValidatingVisitor.java:99) [info] at org.everit.json.schema.Visitor.visitArraySchema(Visitor.java:64) [info] at org.everit.json.schema.ArraySchemaValidatingVisitor.visitArraySchema(ArraySchemaValidatingVisitor.java:37) [info] at org.everit.json.schema.ArraySchema.accept(ArraySchema.java:211) [info] at org.everit.json.schema.ValidatingVisitor.visitArraySchema(ValidatingVisitor.java:73) [info] at org.everit.json.schema.ArraySchema.accept(ArraySchema.java:211) [info] at org.everit.json.schema.Visitor.visit(Visitor.java:48) [info] at org.everit.json.schema.ValidatingVisitor.visit(ValidatingVisitor.java:52) [info] at org.everit.json.schema.ValidatingVisitor.lambda$getFailureOfSchema$1(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidationFailureReporter.inContextOfSchema(ValidationFailureReporter.java:34) [info] at org.everit.json.schema.CollectingFailureReporter.inContextOfSchema(CollectingFailureReporter.java:25) [info] at org.everit.json.schema.ValidatingVisitor.getFailureOfSchema(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidatingVisitor.visitCombinedSchema(ValidatingVisitor.java:157) [info] at org.everit.json.schema.CombinedSchema.accept(CombinedSchema.java:186) [info] at org.everit.json.schema.Visitor.visit(Visitor.java:48) [info] at org.everit.json.schema.ValidatingVisitor.visit(ValidatingVisitor.java:52) [info] at org.everit.json.schema.ValidatingVisitor.lambda$getFailureOfSchema$1(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidationFailureReporter.inContextOfSchema(ValidationFailureReporter.java:34) [info] at org.everit.json.schema.CollectingFailureReporter.inContextOfSchema(CollectingFailureReporter.java:25) [info] at org.everit.json.schema.ValidatingVisitor.getFailureOfSchema(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidatingVisitor.visitReferenceSchema(ValidatingVisitor.java:132) [info] at org.everit.json.schema.ReferenceSchema.accept(ReferenceSchema.java:168) [info] at org.everit.json.schema.Visitor.visit(Visitor.java:48) [info] at org.everit.json.schema.ValidatingVisitor.visit(ValidatingVisitor.java:52) [info] at org.everit.json.schema.ValidatingVisitor.lambda$getFailureOfSchema$1(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidationFailureReporter.inContextOfSchema(ValidationFailureReporter.java:34) [info] at org.everit.json.schema.CollectingFailureReporter.inContextOfSchema(CollectingFailureReporter.java:25) [info] at org.everit.json.schema.ValidatingVisitor.getFailureOfSchema(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ObjectSchemaValidatingVisitor.visitPropertySchema(ObjectSchemaValidatingVisitor.java:158) [info] at org.everit.json.schema.Visitor.visitPropertySchemas(Visitor.java:182) [info] at org.everit.json.schema.Visitor.visitObjectSchema(Visitor.java:164) [info] at org.everit.json.schema.ObjectSchemaValidatingVisitor.visitObjectSchema(ObjectSchemaValidatingVisitor.java:36) [info] at org.everit.json.schema.ObjectSchema.accept(ObjectSchema.java:266) [info] at org.everit.json.schema.ValidatingVisitor.visitObjectSchema(ValidatingVisitor.java:143) [info] at org.everit.json.schema.ObjectSchema.accept(ObjectSchema.java:266) [info] at org.everit.json.schema.Visitor.visit(Visitor.java:48) [info] at org.everit.json.schema.ValidatingVisitor.visit(ValidatingVisitor.java:52) [info] at org.everit.json.schema.ValidatingVisitor.lambda$getFailureOfSchema$1(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidationFailureReporter.inContextOfSchema(ValidationFailureReporter.java:34) [info] at org.everit.json.schema.CollectingFailureReporter.inContextOfSchema(CollectingFailureReporter.java:25) [info] at org.everit.json.schema.ValidatingVisitor.getFailureOfSchema(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidatingVisitor.visitReferenceSchema(ValidatingVisitor.java:132) [info] at org.everit.json.schema.ReferenceSchema.accept(ReferenceSchema.java:168) [info] at org.everit.json.schema.Visitor.visit(Visitor.java:48) [info] at org.everit.json.schema.ValidatingVisitor.visit(ValidatingVisitor.java:52) [info] at org.everit.json.schema.ValidatingVisitor.lambda$getFailureOfSchema$1(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidationFailureReporter.inContextOfSchema(ValidationFailureReporter.java:34) [info] at org.everit.json.schema.CollectingFailureReporter.inContextOfSchema(CollectingFailureReporter.java:25) [info] at org.everit.json.schema.ValidatingVisitor.getFailureOfSchema(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ConditionalSchemaValidatingVisitor.visitThenSchema(ConditionalSchemaValidatingVisitor.java:53) [info] at java.util.Optional.ifPresent(Optional.java:159) [info] at org.everit.json.schema.Visitor.visitConditionalSchema(Visitor.java:248) [info] at org.everit.json.schema.ConditionalSchemaValidatingVisitor.visitConditionalSchema(ConditionalSchemaValidatingVisitor.java:35) [info] at org.everit.json.schema.ConditionalSchema.accept(ConditionalSchema.java:68) [info] at org.everit.json.schema.ValidatingVisitor.visitConditionalSchema(ValidatingVisitor.java:178) [info] at org.everit.json.schema.ConditionalSchema.accept(ConditionalSchema.java:68) [info] at org.everit.json.schema.Visitor.visit(Visitor.java:48) [info] at org.everit.json.schema.ValidatingVisitor.visit(ValidatingVisitor.java:52) [info] at org.everit.json.schema.ValidatingVisitor.lambda$getFailureOfSchema$1(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidationFailureReporter.inContextOfSchema(ValidationFailureReporter.java:34) [info] at org.everit.json.schema.CollectingFailureReporter.inContextOfSchema(CollectingFailureReporter.java:25) [info] at org.everit.json.schema.ValidatingVisitor.getFailureOfSchema(ValidatingVisitor.java:192) [info] at org.everit.json.schema.ValidatingVisitor.visitCombinedSchema(ValidatingVisitor.java:157) [info] at org.everit.json.schema.CombinedSchema.accept(CombinedSchema.java:186) [info] at org.everit.json.schema.Visitor.visit(Visitor.java:48) [info] at org.everit.json.schema.ValidatingVisitor.visit(ValidatingVisitor.java:52) [info] at org.everit.json.schema.DefaultValidator.performValidation(Validator.java:70) [info] at org.everit.json.schema.Schema.validate(Schema.java:152)
If I remove this block, validation works perfectly.
From my debug investigation, the problem would be situated here :
arraySchema.getItemSchemas().size()
arraySchema.itemSchemas
is null
However, I don’t know why it is empty.
I use the latest version : 0.12.1
Here is a sample from Google :
{
"@context": "http://schema.org",
"@type": "DataFeed",
"dateModified": "2018-07-20T00:44:51Z",
"dataFeedElement": [
{
"@context": ["http://schema.org", {"@language": "en"}],
"@type": "Movie",
"@id": "http://www.example.com/my_favorite_movie",
"url": "http://www.example.com/my_favorite_movie",
"name": "My Favorite Movie",
"potentialAction": {
"@type": "WatchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "http://www.example.com/my_favorite_movie?autoplay=true",
"inLanguage": "en",
"actionPlatform": [
"http://schema.org/DesktopWebPlatform",
"http://schema.org/MobileWebPlatform",
"http://schema.org/AndroidPlatform",
"http://schema.org/AndroidTVPlatform",
"http://schema.org/IOSPlatform",
"http://schema.googleapis.com/GoogleVideoCast"
]
},
"actionAccessibilityRequirement": {
"@type": "ActionAccessSpecification",
"category": "subscription",
"requiresSubscription": {
"@type": "MediaSubscription",
"name": "Example Package",
"commonTier": true,
"@id": "[partner determined string]",
"identifier": "example.com:example_package"
},
"availabilityStarts": "2018-07-21T10:35:29Z",
"availabilityEnds": "2019-10-21T10:35:29Z",
"eligibleRegion": [
{
"@type": "Country",
"name": "US"
},
{
"@type": "Country",
"name": "CA"
}
]
}
},
"sameAs": "https://en.wikipedia.org/wiki/my_favorite_movie",
"releasedEvent": {
"@type": "PublicationEvent",
"startDate": "2008-01-20",
"location": {
"@type": "Country",
"name": "US"
}
},
"description": "This is my favorite movie.",
"actor": [
{
"@type": "Person",
"name": "John Doe",
"sameAs": "https://en.wikipedia.org/wiki/John_Doe"
},
{
"@type": "Person",
"name": "Jane Doe",
"sameAs": "https://en.wikipedia.org/wiki/Jane_Doe"
}
],
"identifier": [
{
"@type": "PropertyValue",
"propertyID": "IMDB_ID",
"value": "tt0123456"
}
]
}
]
}
Best regards,
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hello @Ekzer , I merged @zgyorffi 's PR fixing the issue: #374
Hi Ekzer, Thanks for raising this issue! The itemSchemas is null because there is no schemas defined under “items” keyword. Of course exception should not be thrown so it is certainly a bug and I think it can be fixed quite easily. Keep in mind that according to 9.3.1.2. in the core specification in this case the validation of the item against the schema under “additionalItems” should be skipped at all.