Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct handling when empty GraphQL requests arrive #20293

Closed
jmartisk opened this issue Sep 21, 2021 · 1 comment · Fixed by #20295
Closed

Correct handling when empty GraphQL requests arrive #20293

jmartisk opened this issue Sep 21, 2021 · 1 comment · Fixed by #20295
Assignees
Labels
Milestone

Comments

@jmartisk
Copy link
Contributor

Describe the bug

When an empty POST request arrives at the /graphql endpoint, the client receives a 500 Internal Server Error and this appears in the log:

2021-09-21 08:53:19,800 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (vert.x-eventloop-thread-4) HTTP Request to /graphql/ failed, error id: 87f1643d-a786-485b-89c4-6d105c1c1ea8-1: java.lang.NullPointerException
	at java.base/java.io.StringReader.<init>(StringReader.java:50)
	at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.getJsonObjectFromBody(SmallRyeGraphQLExecutionHandler.java:173)
	at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.handlePost(SmallRyeGraphQLExecutionHandler.java:89)
	at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLExecutionHandler.doHandle(SmallRyeGraphQLExecutionHandler.java:70)
	at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLAbstractHandler.handleWithIdentity(SmallRyeGraphQLAbstractHandler.java:66)
	at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLAbstractHandler.handle(SmallRyeGraphQLAbstractHandler.java:48)
	at io.quarkus.smallrye.graphql.runtime.SmallRyeGraphQLAbstractHandler.handle(SmallRyeGraphQLAbstractHandler.java:23)
	at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
	at io.vertx.core.impl.ContextImpl.lambda$null$0(ContextImpl.java:159)
	at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:100)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$1(ContextImpl.java:157)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)

an empty GET request yields 204 No Content

Expected behavior

I believe that the correct behavior for both cases is to issue 400 Bad Request, per the spec: https://github.com/graphql/graphql-over-http/blob/40a50a351a887799b3d1550b665b2101b26dcda4/spec/GraphQLOverHTTP.md#unparseable-or-invalid-request-body

Actual behavior

No response

How to Reproduce?

curl -v -H"Content-Type: application/json" -X POST localhost:8080/graphql
curl -v -H"Content-Type: application/json" -X GET localhost:8080/graphql/

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@jmartisk jmartisk added kind/bug Something isn't working area/graphql labels Sep 21, 2021
@jmartisk jmartisk self-assigned this Sep 21, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 21, 2021

/cc @phillip-kruger

@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Sep 21, 2021
@gsmet gsmet modified the milestones: 2.3.0.CR1, 2.2.4.Final Nov 30, 2021
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 5, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 6, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 7, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 10, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 10, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 10, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 10, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 10, 2022
fedinskiy added a commit to fedinskiy/quarkus-test-suite that referenced this issue Jan 10, 2022
fedinskiy added a commit to quarkus-qe/quarkus-test-suite that referenced this issue Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants