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

Cannot specify same parameter twice in the query #197

Open
dcermak opened this issue Oct 28, 2024 · 1 comment
Open

Cannot specify same parameter twice in the query #197

dcermak opened this issue Oct 28, 2024 · 1 comment

Comments

@dcermak
Copy link
Contributor

dcermak commented Oct 28, 2024

osctiny's handling of dictionary parameters to osc.request prevents the creation of url parameters like &view=status&view=binarylist. requests supports this via:

param = {"view": ["status", "binarylist"]}

but the handling inside Osc.handle_params prevents this behavior from applying:

return "&".join(

Could such parameters be supported? It is sadly required to fully utilize some buildservice routes without calling the API endpoint twice or three times

@crazyscientist
Copy link
Collaborator

crazyscientist commented Oct 29, 2024

For illustration:

>>> from osctiny import Osc
>>> o = Osc("https://api.opensuse.org")
>>> r = o.request("http://example.com", params={"view": ["a", "b"]})
>>> print(r.url)
http://example.com/?view=%5B%27a%27%2C%20%27b%27%5D
>>> r = o.session.get("http://example.com", params={"view": ["a", "b"]})
>>> print(r.url)
http://example.com/?view=a&view=b

Notice the difference: The latter "correctly" translates the list for the view parameter to multiple key-value pairs in the query. The former incorrectly converts the list to a string and escapes it.

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

No branches or pull requests

2 participants