Skip to content

NonNullableValueCoercedAsNullException being thrown in QueryTraversal #2761

@bbakerman

Description

@bbakerman

Discussed in #2760

Originally posted by slisaasquatch March 12, 2022
I'm seeing random NonNullableValueCoercedAsNullExceptions from our servers running graphql-java 17.3 with graphql-java-tools 12.0.2. I've logged the entire GraphQL query, variables, and operation name, and I cannot reproduce the exception. The stack trace looks like this:

graphql.execution.NonNullableValueCoercedAsNullException: Field '' has coerced Null value for NonNull type 'String!'
	at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:493)
	at graphql.execution.ValuesResolver.lambda$externalValueToInternalValueForList$2(ValuesResolver.java:604)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)
	at graphql.execution.ValuesResolver.externalValueToInternalValueForList(ValuesResolver.java:605)
	at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:507)
	at graphql.execution.ValuesResolver.externalValueToInternalValueForObject(ValuesResolver.java:570)
	at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:510)
	at graphql.execution.ValuesResolver.externalValueToInternalValue(ValuesResolver.java:491)
	at graphql.execution.ValuesResolver.externalValueToInternalValueForVariables(ValuesResolver.java:412)
	at graphql.execution.ValuesResolver.coerceVariableValues(ValuesResolver.java:94)
	at graphql.analysis.QueryTraverser.coerceVariables(QueryTraverser.java:64)
	at graphql.analysis.QueryTraverser.<init>(QueryTraverser.java:60)
	at graphql.analysis.QueryTraverser.<init>(QueryTraverser.java:40)
	at graphql.analysis.QueryTraverser$Builder.build(QueryTraverser.java:297)
	at graphql.analysis.MaxQueryDepthInstrumentation.newQueryTraverser(MaxQueryDepthInstrumentation.java:92)
	at graphql.analysis.MaxQueryDepthInstrumentation.lambda$beginValidation$2(MaxQueryDepthInstrumentation.java:57)
	at graphql.execution.instrumentation.SimpleInstrumentationContext.onCompleted(SimpleInstrumentationContext.java:51)
	at graphql.execution.instrumentation.ChainedInstrumentation$ChainedInstrumentationContext.lambda$onCompleted$1(ChainedInstrumentation.java:238)
	at graphql.com.google.common.collect.ImmutableList.forEach(ImmutableList.java:405)
	at graphql.execution.instrumentation.ChainedInstrumentation$ChainedInstrumentationContext.onCompleted(ChainedInstrumentation.java:238)
	at graphql.GraphQL.validate(GraphQL.java:600)
	at graphql.GraphQL.parseAndValidate(GraphQL.java:562)
	at graphql.GraphQL.lambda$parseValidateAndExecute$10(GraphQL.java:531)
	at graphql.execution.preparsed.NoOpPreparsedDocumentProvider.getDocument(NoOpPreparsedDocumentProvider.java:15)
	at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:533)
	at graphql.GraphQL.executeAsync(GraphQL.java:502)

Can someone please give me some general directions on what the error means?

I know if I put a null inside an array that requires non null values in variables, I can cause an error with the same error message. However, if you look at the stack trace, the exception was thrown at graphql.GraphQL.executeAsync, meaning I'm not even getting a result from it.

Also for the record, this is what my variables looks like:

{
  "accountId": "133...63",
  "userId": "133...63",
  "userInput": {
    "accountId": "133...63",
    "id": "133...63"
  }
}

I do not have arrays or nulls in my variables.

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