Skip to content

fix(client): ensure encoded query params are never duplicated #2219

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
merged 2 commits into from
Aug 4, 2022

Conversation

nejch
Copy link
Member

@nejch nejch commented Aug 4, 2022

Closes #2218

This provides a small generic fix at the http_request level instead of messing even more with our own flows.

(I've always thought it was a bit weird that GitLab returns a lot of boilerplate query params in ther next header links, so I think this will also make other things more robust in the future).

@nejch nejch changed the title test(unit): reproduce duplicate encoded query params fix(client): ensure encoded query params are never duplicated Aug 4, 2022
@nejch nejch marked this pull request as ready for review August 4, 2022 13:54
@max-wittig max-wittig merged commit d263f57 into main Aug 4, 2022
@max-wittig max-wittig deleted the fix/no-duplicate-params branch August 4, 2022 14:36
utils.copy_dict(src=query_data, dest=params)

url = raw_url.replace(parsed.query, "").strip("?")
Copy link
Member

Choose a reason for hiding this comment

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

Why not use parse.urlunparse?

url = parse.urlunparse(parsed._replace(query=""))

Copy link
Member Author

Choose a reason for hiding this comment

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

I saw that on stackoverflow as well but it uses a private method (_replace) so didn't want to touch that 😁

Copy link
Member

@JohnVillalovos JohnVillalovos Aug 4, 2022

Choose a reason for hiding this comment

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

Oh it is documented in the official docs:

https://docs.python.org/3/library/urllib.parse.html

As is the case with all named tuples, the subclass has a few additional methods and attributes that are particularly useful. One such method is _replace(). The _replace() method will return a new ParseResult object replacing specified fields with new values.

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.

URL-encoded kwargs are infinitely duplicated in query params (v3.7.0 regression for arrays)
3 participants