You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
List merge requests using specific approver_ids regression #1698
[21:49:48] DEBUG Starting new HTTPS connection (1): *redacted*:443 connectionpool.py:971
DEBUG https://*redacted*:443 "GET /api/v4/user HTTP/1.1" 200 None connectionpool.py:452
[21:49:49] DEBUG https://*redacted*:443 "GET /api/v4/groups/475 HTTP/1.1" 200 None connectionpool.py:452
DEBUG https://*redacted*:443 "GET connectionpool.py:452
/api/v4/groups/475/merge_requests?state=opened&author_id=423&approver_ids=423
HTTP/1.1" 400 60
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gitlab/exceptions.py", line 304, in wrapped_f
return f(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/gitlab/mixins.py", line 242, in list
obj = self.gitlab.http_list(path, **data)
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 718, in http_list
return list(GitlabList(self, url, query_data, **kwargs))
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 881, in __init__
self._query(url, query_data, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 891, in _query
result = self._gl.http_request("get", url, query_data=query_data, **kwargs)
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 628, in http_request
raise gitlab.exceptions.GitlabHttpError(
gitlab.exceptions.GitlabHttpError: 400: approver_ids should be an array, 'None' or 'Any'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "*redacted*.py", line 30, in <module>
group_mrs = group.mergerequests.list(
File "/usr/local/lib/python3.9/site-packages/gitlab/exceptions.py", line 306, in wrapped_f
raise error(e.error_message, e.response_code, e.response_body) from e
gitlab.exceptions.GitlabListError: 400: approver_ids should be an array, 'None' or 'Any'
Expected Behavior
Return merge requests for the specified approver_ids.
Likely we need to add support for doing approver_ids[]=423 (which is adding []).
Unfortunatly, I havn't found an example on in the Gitlab docs on how to encode the array, but guessing from this post, the URL argument may be approver_ids[]=423 just like you wrote.
My guess is because there is only one item in the list it doesn't like it.
[22:37:00] DEBUG Starting new HTTPS connection (1): *redacted*:443 connectionpool.py:971
DEBUG https://*redacted*:443 "GET /api/v4/user HTTP/1.1" 200 None connectionpool.py:452
[22:37:01] DEBUG https://*redacted*:443 "GET /api/v4/groups/475 HTTP/1.1" 200 None connectionpool.py:452
DEBUG https://*redacted*:443 "GET connectionpool.py:452
/api/v4/groups/475/merge_requests?state=opened&author_id=423&approver_ids=11%2C423
HTTP/1.1" 400 60
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/gitlab/exceptions.py", line 304, in wrapped_f
return f(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/gitlab/mixins.py", line 242, in list
obj = self.gitlab.http_list(path, **data)
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 718, in http_list
return list(GitlabList(self, url, query_data, **kwargs))
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 881, in __init__
self._query(url, query_data, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 891, in _query
result = self._gl.http_request("get", url, query_data=query_data, **kwargs)
File "/usr/local/lib/python3.9/site-packages/gitlab/client.py", line 628, in http_request
raise gitlab.exceptions.GitlabHttpError(
gitlab.exceptions.GitlabHttpError: 400: approver_ids should be an array, 'None' or 'Any'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "*redacted*.py", line 30, in <module>
group_mrs = group.mergerequests.list(
File "/usr/local/lib/python3.9/site-packages/gitlab/exceptions.py", line 306, in wrapped_f
raise error(e.error_message, e.response_code, e.response_body) from e
gitlab.exceptions.GitlabListError: 400: approver_ids should be an array, 'None' or 'Any'
Unfortunatly, I havn't found an example on in the Gitlab docs on how to encode the array, but guessing from this post, the URL argument may be approver_ids[]=423 just like you wrote.
It is supposed to be something like: approver_ids[]=11&approver_ids[]=423 in the actual HTTP request. Though currently it will also work as approver_ids=11,423 as it understands a comma separated string is a list.
Ah, looks like the comma gets URL-encoded there so that might be related to #1356 and similar. Or, maybe it's meant to be encoded I should probably check first :D
I believe the URL encoding there is correct. I dug into it a bit and it is done by requests.
I think it should work for 1 ID in the list but unsure if 2 or more IDs were in the approver_ids list. Not sure how the GitLab server will react to that...
Activity
JohnVillalovos commentedon Nov 18, 2021
Related issue: #1419
My guess is because there is only one item in the list it doesn't like it.
Likely we need to add support for doing
approver_ids[]=423(which is adding[]).skycaptain commentedon Nov 18, 2021
Unfortunatly, I havn't found an example on in the Gitlab docs on how to encode the array, but guessing from this post, the URL argument may be
approver_ids[]=423just like you wrote.Hmm, having the same issue with two user ids:
JohnVillalovos commentedon Nov 18, 2021
https://docs.gitlab.com/ee/api/#array
So if
approver_ids=[11, 423]It is supposed to be something like:
approver_ids[]=11&approver_ids[]=423in the actual HTTP request. Though currently it will also work asapprover_ids=11,423as it understands a comma separated string is a list.JohnVillalovos commentedon Nov 18, 2021
I dug into this a bit more:
approver_idsandapproved_by_idsis the only one to use the validator: https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/api/validations/validators/array_none_any.rb which is what generates that error message.CommaSeparatedToArraywhich accepts the comma-separated values.So to fix this we need to send the arrays in the proper way.
JohnVillalovos commentedon Nov 18, 2021
I believe the URL encoding there is correct. I dug into it a bit and it is done by
requests.JohnVillalovos commentedon Nov 19, 2021
I have a draft PR that might fix this: #1699
I think it should work for 1 ID in the list but unsure if 2 or more IDs were in the
approver_idslist. Not sure how the GitLab server will react to that...fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
JohnVillalovos commentedon Nov 20, 2021
@skycaptain #1699 is available which should resolve the issue. In my testing it is working to fix this issue.
skycaptain commentedon Nov 21, 2021
@JohnVillalovos works!
JohnVillalovos commentedon Nov 21, 2021
Awesome. Thank you for testing it @skycaptain !
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
26 remaining items
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables
fix: use the [] after key names for array variables in `params`
test: add test to show issue fixed