atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.34k stars 661 forks source link

[Bitbucket Cloud] In .each, the q parameter does not support lists #1184

Open BraxtonLowers opened 1 year ago

BraxtonLowers commented 1 year ago

When attempting to expand the filter to include multiple pull request states in

repository.pullrequests.each(q=['state="OPEN"','state="DECLINED"', 'state="MERGED"']

the bitbucket REST url forms improperly, treating the inner list value as a string to be urlencoded. On deeper inspection I found that the urlencode function in the request() method of AtlassianRestAPI in atlassian/rest_client.py (imported from urllib.parse) accepts an additional parameter for handling this case called doseq. It defaults to False and is not specified in the AtlassianRestAPI.request call, but if set to True, urlencode handles the inner list (as well as just passing strings) and expected behavior returns.

My only concern with providing a PR is that this is heavily reused functionality, and that urlencode can only differentiate between bytes, string, and sequence objects, so if any other function passes an iterable to the query param argument and expects prior behavior, those use cases may break. Are there automated tests to ensure I don't introduce any regressions? Or is this something that would be manually validated during review of the pull request?

djgoku commented 1 year ago

I would try:

repository.pullrequests.each(q="state=\"OPEN\" OR state=\"DECLINED\" OR state=\"MERGED\"")