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

Upgrade okhttp3 to latest #231

Closed
wants to merge 9 commits into from
Closed

Upgrade okhttp3 to latest #231

wants to merge 9 commits into from

Conversation

usulkies
Copy link

@usulkies usulkies commented Nov 12, 2019

Changes

Upgrading the okhttp3 version to the latest on the 3.x line

Change few tests assertion to match encoded URL

References

N/A

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

  • This change adds test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@usulkies usulkies requested a review from a team November 12, 2019 12:16
@@ -106,7 +106,7 @@ public void shouldListLogEventsWithQuery() throws Exception {
assertThat(recordedRequest, hasMethodAndPath("GET", "/api/v2/logs"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("q", "email%3A%5C*%40gmail.com"));
assertThat(recordedRequest, hasQueryParameter("q", "email:\\*@gmail.com"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this change on behavior could be a breaking change??

Copy link
Author

Choose a reason for hiding this comment

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

@lbalmaceda
This is my confession:
I'm not a real contributor to auth0...
I'm just suffering from dependency convergence. We're using Zipkin for tracing reporting, and it's already using version 3.14.3 of okhttp3.
For some reason, the auth0 project, which we're also using, is still back on version 3.9.1.
I fear these 2 versions are not compatible.
So I tried to just upgrade the okhttp3 version but found out that some tests are breaking, probably because of changes made between these versions handling URL encoding.
I'll be happy if someone who really understands what is the use of okhttp3 for auth0 will be able to handle this version bump.
I think it's important for auth0 to remain relevant for users, to always try and bump to the latest dependencies versions. Consider using @dependabot for this.
Could you please help with this?
Thanks a lot,
Uziel

@usulkies
Copy link
Author

usulkies commented Dec 9, 2019

@lbalmaceda
I tried another solution, after digging the changes a bit.
I changed the code in a way that preserves expected behavior as documented in tests.
Did it be replacing all calls to HttpUrl.addQueryParameter to HttpUrl.addEncodedQueryParameter.
The other method do not try to encode the value as the first is now doing (it didn't do it in the old version of okhttp3).
I hope now it'll be approved. 🙂
Thanks for your review!

@usulkies usulkies requested a review from lbalmaceda December 11, 2019 10:37
@lbalmaceda
Copy link
Contributor

@usulkies Thanks for the keep looking for a workaround to keep the tests untouched.
I have to say it looks odd if we need to change every mention of addQueryParameter, especially because addEncodedQueryParameter is meant to skip the UTF8 encoding step and add it as is. If anything, a problem would raise when weird ASCII chars are being used. I fear to block the authentication of users if we happen to break it with this PR.

Give me a few days to try this out manually, please.

@lbalmaceda lbalmaceda self-assigned this Dec 26, 2019
@usulkies
Copy link
Author

Give me a few days to try this out manually, please.

Hi @lbalmaceda ,
Any news?

@lbalmaceda
Copy link
Contributor

@usulkies I couldn't check this yet. Let me add a backlog item so at least the team is aware.

@MorrisonCole
Copy link

MorrisonCole commented Feb 4, 2020

Ran into this as well and raised #236 before I noticed this PR. This is really quite an old dependency now 😅

@lbalmaceda
Copy link
Contributor

@usulkies Sorry for the delay here. We're going through some issues categorization and we think this is something worth adding to the SDK. We will investigate and test a bit the changes in terms of char encoding, and would need to bump the OkHttp version to the latest 3.x. Is that something you can do in the meantime?
Thanks!

@lbalmaceda lbalmaceda added the dependencies One or more dependencies are being bumped label Apr 3, 2020
@usulkies
Copy link
Author

@usulkies Sorry for the delay here. We're going through some issues categorization and we think this is something worth adding to the SDK. We will investigate and test a bit the changes in terms of char encoding, and would need to bump the OkHttp version to the latest 3.x. Is that something you can do in the meantime?
Thanks!

Hi @lbalmaceda I'm not sure I understood your question. What would you like me to do in the meantime?

@lbalmaceda
Copy link
Contributor

👋 that would be bumping to the current latest version, which according to maven central is 3.14.9. I'm planning to bring this issue up in our next planning meeting.

@usulkies
Copy link
Author

👋 that would be bumping to the current latest version, which according to maven central is 3.14.9. I'm planning to bring this issue up in our next planning meeting.

Done

@usulkies
Copy link
Author

@lbalmaceda When is the next planning meeting? Can you guess when we'll have this released?
It is currently a blocker for other libraries I'm using that I can't bump because they require a higher version of okhttp3 and it will break auth0.

@jimmyjames
Copy link
Contributor

Hi @usulkies, I'm going to be reviewing this and will be following up this week. Thanks!

@jimmyjames
Copy link
Contributor

Regarding the issues observed with tests failing prior to updating some usages to addEncodedQueryParameter is that starting in version 3.10.0, OkHttp started URL-encoding more characters (I believe this is the commit). This caused query params with the newly encoded characters (such as /, ,, @, =, among others) to be URL-encoded, which in itself is a good thing, but the tests were expecting the old behavior prior to that change.

Rather than changing to not URL encode query parameters (which is what addEncodedQueryParameter does), the better fix is to the tests themselves. And actually, very few tests would need updating, as we have a custom matcher that we can update to get the query params back from the URL.

@usulkies I've gotten this working locally, so instead of asking you to revert your changes on this PR to use addEncodedQueryParameter and update the request matcher, I'll follow up shortly with a new PR targeting the same version of OkHttp 👍

@jimmyjames jimmyjames mentioned this pull request May 27, 2020
5 tasks
@jimmyjames
Copy link
Contributor

Closing this PR as it has been addressed in #262. We are hoping to do a release by the end of this week that will include this change; I'll follow up here when that's done. Thanks for your patience all! 🙇

@jimmyjames jimmyjames closed this May 27, 2020
@usulkies usulkies deleted the update_okhttp3 branch May 31, 2020 06:23
@usulkies
Copy link
Author

Thanks @jimmyjames !
This is really helpful!

@jimmyjames
Copy link
Contributor

Just to make sure to close this loop - version 1.18.0 was released Friday and includes an update to use OkHttp 3.14.9 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies One or more dependencies are being bumped
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants