question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException on visitSchemaOnAdditionalItems with special types

See original GitHub issue

Hello, 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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
erosbcommented, Jul 7, 2020

Hello @Ekzer , I merged @zgyorffi 's PR fixing the issue: #374

1reaction
zgyorfficommented, Jul 5, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix and Avoid NullPointerException in Java - Rollbar
NullPointerException in Java occurs when a variable is accessed which is not pointing to any object and refers to nothing or null.
Read more >
java - What is a NullPointerException, and how do I fix it?
Reference types in Java allow you to use the special value null which is the Java way of saying "no object". A NullPointerException...
Read more >
What Is NullPointerException In Java & How To Avoid It
Null Pointer Exception is thrown in specific scenarios in Java. Some of the scenarios are as follows: Method invoked using a null object....
Read more >
NullPointerException in Java: Causes and Ways to Avoid It
Java provides Compile Type Safety and it gives a guarantee to the developer that he can't mismatch different variables types.
Read more >
Java NullPointerException - Detect, Fix, and Best Practices
Some of the common reasons for NullPointerException in java programs are: ... HTTP Status 500 – Internal Server Error Type Exception Report ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found