quarkus
quarkus copied to clipboard
NullPointerException on GraphqQL server when request has syntax errors
Describe the bug
GraphQL server swallows syntax errors in request and throws NullPointeException.
Expected behavior
Invalid syntax error is returned to client. E.g. Invalid Syntax : offending token '[' at line 1 column 1
Actual behavior
Original Invalid syntax error is swallowed. Request failed later with NPE that is returned to client.
ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-0) HTTP Request to /graphql failed, error id: 2883077a-96a7-42a9-9ff3-148a04feb8a0-1: java.lang.NullPointerException: Cannot invoke "graphql.language.Document.getDefinitionsOfType(java.lang.Class)" because "document" is null
at io.smallrye.graphql.execution.context.SmallRyeContextManager.getRequestedOperationTypes(SmallRyeContextManager.java:253)
at io.smallrye.graphql.execution.context.SmallRyeContextManager.populateFromExecutionInput(SmallRyeContextManager.java:102)
at io.smallrye.graphql.execution.ExecutionService.execute(ExecutionService.java:155)
at io.smallrye.graphql.execution.ExecutionService.executeAsync(ExecutionService.java:105)
at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.doRequest(SmallRyeGraphQLExecutionHandler.java:296)
at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.handlePost(SmallRyeGraphQLExecutionHandler.java:116)
at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.doHandle(SmallRyeGraphQLExecutionHandler.java:77)
at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLAbstractHandler.handleWithIdentity(SmallRyeGraphQLAbstractHandler.java:95)
at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLAbstractHandler.handle(SmallRyeGraphQLAbstractHandler.java:76)
at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLAbstractHandler.handle(SmallRyeGraphQLAbstractHandler.java:30)
How to Reproduce?
Send any request with syntax error (e.g. "[]") to graphql service using any client (e.g. graphql-ui).
Output of uname -a
or ver
Darwin TEAL 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
Output of java -version
openjdk 17.0.4 2022-07-19
GraalVM version (if different from Java)
OpenJDK Runtime Environment GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06)
Quarkus version or git rev
2.12.0.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
Gradle 7.5.1
Additional information

/cc @jmartisk, @phillip-kruger
@jmartisk @phillip-kruger I really think we need to address this as it's an annoying issue for anyone using the GraphQL UI.
I can certainly provide a dump fix myself in smallry-graphql, but I am certain it won't be the proper solution as I don't have any of the necessary context
Sure, we will look at this a.s.a.p. We can move this to SmallRye and close here ?
Sounds good to me
@phillip-kruger Any update on this? Seems like I'm still facing this issue ...
This was fixed in SmallRye GraphQL 2.1.0, so that will be in Quarkus 3.0. With a build of the current Quarkus main
branch, the response with the error is this:
{
"errors": [
{
"message": "Unparseable input document",
"locations": [],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": null
}
@jmartisk thanks! I've just tested it with current release (2.16.X). Anyhow, seems like a backport isn't planned?
@chberger, ok I'll prepare a backport to 2.16, it might get into 2.16.5 or 2.16.6, not sure about the current exact schedule
@jmartisk I can wait for you if you plan to push the fix soon.
Ok I've kicked off a release of SmallRye GraphQL 1.9.4. If it passes, I can send an upgrade PR to Quarkus later today. Or anybody else can, simply bumping the version should be enough.
@jmartisk I created the PR and asked for your approval there.
@chberger, ok I'll prepare a backport to 2.16, it might get into 2.16.5 or 2.16.6, not sure about the current exact schedule
Cool :-) Thank you!
As the fix is now in 2.16.5 and in the main branch, I think we can close this now.