Skip to content

adding checks for json end_document in http transport #5895

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ internal object ResponseParser {

jsonReader.endObject()

if (jsonReader.peek() != JsonReader.Token.END_DOCUMENT) {
println("Apollo: extra tokens after payload")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 things:

  1. Can you move this to the toApolloResponse() function? I'd like to keep the possibility to read a single JSON object from ResponseParser.parse in the future
  2. Let's make it an error? For this you can throw JsonDataException("Expected END_DOCUMENT but was ${peek()}")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made changes (hopefully) - as requested - lmk, and I'll push an equivalent to the 3.x branch.

Also - do you want the same applied to batching interceptor parsing - I'm guessing an exception should also be thrown there, not sure about whether code needs moving around?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made changes (hopefully) - as requested - lmk, and I'll push an equivalent to the 3.x branch.

Thanks, LGTM 👍

Also - do you want the same applied to batching interceptor parsing - I'm guessing an exception should also be thrown there, not sure about whether code needs moving around?

Yup, same exception, no need to move code around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, Ive pushed a similar change to the other 3 prs.
not sure whether I should investigate integration test failures here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, Ive pushed a similar change to the other 3 prs.

Thanks!

not sure whether I should investigate integration test failures here?

Doesn't look related, I'll take a deeper look tomorrow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out it was related. peek() can throw but toApolloResponse() shouldn't. See 9ab202c

I'll take it from there for this PR and the other 3. Thanks again for looking into this!


return ApolloResponse.Builder(operation = operation, requestUuid = requestUuid ?: uuid4())
.errors(errors)
.data(data)
Expand Down
Loading