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

[bug] GraphQL server returns 500 when sending empty json payload #2195

Open
nitram509 opened this issue Oct 13, 2024 · 0 comments
Open

[bug] GraphQL server returns 500 when sending empty json payload #2195

nitram509 opened this issue Oct 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@nitram509
Copy link
Contributor

Describe the bug

When empty or broken JSON is send to the /query endpoint, a 500 internal error is returned, which is mis-leading and should be a 400 bad request instead.

To Reproduce
Steps to reproduce the behavior:

  1. Start the graphql server
  2. fire a post request to the /query endpoint, wih a payload of 0 bytes

Actual behaviour

Input (raw) sent:

POST /query HTTP/1.1
user-agent: guac-visualizer
accept: application/json
accept-encoding: gzip, deflate, br
Host: localhost:8080
Connection: keep-alive
Content-Length: 0

The server returns status 500 unexpected end of JSON input
Raw reponse from the server:

HTTP/1.1 500 Internal Server Error
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Sun, 13 Oct 2024 18:06:52 GMT
Content-Length: 29

unexpected end of JSON input

Expected behaviour
Since this is related to user input data, a status code 400 "bad request" should be used.
Also the error message could be a bit more proactive: e.g. fmt.Sprintf("provided input json couldn't be parsed. likely it was empty or was wrongly structured; error message: %v", err.String()).
When I developed a reverse proxy for the visualizer, I was completely puzzled and mis-lead because of the 500 error and thought of a bigger issue inside GraphQL, looked in to the error logs, but couldn't find. spend too much time thinking, until realizing my error was "just" in the empty json payload.

Screenshots
n/a

GUAC version
build from repository, as of Oct. 14th, 2024

Additional context
n/a

@nitram509 nitram509 added the bug Something isn't working label Oct 13, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 18, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 18, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 18, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 18, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 18, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
Signed-off-by: Sithum Sathsara <[email protected]>
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
Signed-off-by: Sithum Sathsara <[email protected]>
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
Signed-off-by: Sithum Sathsara <[email protected]>
000xs added a commit to 000xs/guac that referenced this issue Oct 20, 2024
Signed-off-by: Sithum Sathsara <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant