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

adding checks for json end_document in http transport #5895

Conversation

duzinkie
Copy link
Contributor

the issue is discussed in: #5885

this is the recommended fix for the no http batching scenario, for the main branch

@apollo-cla
Copy link

@duzinkie: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

Copy link

netlify bot commented May 15, 2024

👷 Deploy request for apollo-android-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 9ab202c

@duzinkie duzinkie changed the title adding checks for json end_document in http batching interceptors adding checks for json end_document in http transport May 16, 2024
Comment on lines 48 to 50
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!

@martinbonnin
Copy link
Contributor

Hi @duzinkie 👋 . Want to get this through the finish line?

@duzinkie
Copy link
Contributor Author

Hey @martinbonnin - sorry for the delays, I was on vacation - will be catching up on this this week.

@martinbonnin martinbonnin merged commit 3bcfcbf into apollographql:main Jun 14, 2024
5 checks passed
BoD pushed a commit to BoD/apollo-kotlin that referenced this pull request Jul 1, 2024
…5895)

* adding checks for json end_document in http transport

* moving json end of document parsing to toApolloReponse and turning it into an explicit error, as per PR feedback

* catch exceptions, add some KDoc

---------

Co-authored-by: Martin Bonnin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants