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

graphql: Fix 500 errors on invalid JSON #3499

Merged
merged 3 commits into from
Dec 4, 2023

Conversation

mastercactapus
Copy link
Member

Description:
Handles the case of invalid JSON in a request body to the /api/graphql endpoint.

  • A 400 instead of 500 is returned
  • The parse error is now returned (with body stripped)
  • The common case of sending a non-object has a more clear error message (default would have been cant parse string into Go-type something something)

Which issue(s) this PR fixes:
Fixes #3498

Describe any introduced user-facing changes:
N/A

Describe any introduced API changes:
Invalid JSON will now result in a 400 bad request rather than 500 unexpected error

Additional Info:
Added a smoke test to validate the new behavior.

@mastercactapus mastercactapus merged commit 22083c2 into master Dec 4, 2023
@mastercactapus mastercactapus deleted the make-gql-json-errors-better branch December 4, 2023 17:35
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 this pull request may close these issues.

500 Error Status with Invalid JSON Request on GraphQL Endpoint
3 participants