Skip to content

Null assertion error when a null Locale is set into Validation code #2907

Closed

Description

@softprops

Describe the bug

I'm writing this down as a note but will fill in more information has it comes.

I've just upgraded from 18.2 to 19.0 and am not experiencing a number of errors that look like I'm getting a ton of errors of the form

    => graphql.AssertException: Object required to be not null
       graphql.Assert.assertNotNull(Assert.java:31)
       graphql.i18n.I18n.<init>(I18n.java:37)
       graphql.i18n.I18n.i18n(I18n.java:46)
       graphql.validation.Validator.validateDocument(Validator.java:68)
       graphql.ParseAndValidate.validate(ParseAndValidate.java:111)
       graphql.GraphQL.validate(GraphQL.java:628)
       graphql.GraphQL.parseAndValidate(GraphQL.java:591)
       graphql.GraphQL.lambda$parseValidateAndExecute$10(GraphQL.java:555)
       graphql.execution.preparsed.NoOpPreparsedDocumentProvider.getDocument(NoOpPreparsedDocumentProvider.java:15)
       graphql.execution.preparsed.PreparsedDocumentProvider.getDocumentAsync(PreparsedDocumentProvider.java:4

looking through the changelog this most likely relates to #2878

it looks like this is failing on a null locale --

To Reproduce

Please provide a code example or even better a test to reproduce the bug.

Activity

  1. softprops commented on Aug 1, 2022

    @softprops
    Author

    I think the problem lie here with executionInput.getLocale() which may be null

    List<ValidationError> validationErrors = ParseAndValidate.validate(graphQLSchema, document, validationRulePredicate, executionInput.getLocale());

    passing that along up the chain off calls will eventually nullable to the the runtime error assertNotNull(locale); emits

  2. bbakerman commented on Aug 1, 2022

    @bbakerman
    Member

    Yeah the problem here is the locale is indeed nul..

    ExecutionInput was indeed changed to default it during its builder private Locale locale = Locale.getDefault(); but its possible for a caller to have set it to null (perhaps through calling some other method like customCode.getLocale() returning null.

    We need to default this at the call site.

    As a work around until this gets fixed, people seeing this should ensure that a non null Locale is set into their ExecutionInput

  3. changed the title [-]unclear breaking change in 19.0 update[/-] [+]Null assertion error when a null Locale is set into Validation code[/+] on Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions