-
Couldn't load subscription status.
- Fork 1.1k
Handle JsonParseException #5121
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
Handle JsonParseException #5121
Conversation
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5121 +/- ##
==========================================
Coverage 64.79% 64.80%
- Complexity 14160 14164 +4
==========================================
Files 1733 1733
Lines 67487 67498 +11
Branches 7221 7223 +2
==========================================
+ Hits 43729 43739 +10
Misses 21330 21330
- Partials 2428 2429 +1
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with:
{ "query" : "{stopPlace(id:"NSR:StopPlace:17099"){id name estimatedCalls(timeRange:72100 numberOfDepartures:10){realtime aimedArrivalTime aimedDepartureTime expectedArrivalTime expectedDepartureTime destinationDisplay{frontText}}}}" }
I got a warning in the log:
WARN (GraphQL.java:493) Query did not parse : '{ "query" : "{stopPlace(id:"NSR:StopPlace:17099"){id name estimatedCalls(timeRange:72100 numberOfDepartures:10){realtime aimedArrivalTime aimedDepartureTime expectedArrivalTime expectedDepartureTime destinationDisplay{frontText}}}}" }'
but the return code is still 200 with the following GraphQL response:
{
"errors": [
{
"message": "Invalid syntax with offending token '\"query\"' at line 1 column 3",
"locations": [
{
"line": 1,
"column": 3
}
],
"extensions": {
"classification": "InvalidSyntax"
}
}
]
}
|
JsonParseException is thrown when Content-Type-header is set to |
|
Ok, so this PR covers the case when a request is sent with the content type "application/json" and the content is invalid JSON. In this case the client gets an HTTP 400 status. |
Adds handling of JsonParseException - now returns a
400 Bad Request.This typically occurs when GraphQL-requests contain malformed JSON.