FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

List merge requests using specific approver_ids regression · Issue #1698 · python-gitlab/python-gitlab · GitHub

Repository navigation

List merge requests using specific approver_ids regression #1698

Description

Description of the problem, including code/CLI snippet

There might be a possible regression of #1010 with the latest version. The issue is exactly the same:

group = gl.groups.get(id=475)
group_mrs = group.mergerequests.list(
    all=True,
    state="opened",
    author_id=423,
    approver_ids=[423],
)
[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.

Actual Behavior

Raises an exception.

Specifications

  • python-gitlab version: 2.10.1
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 14.2.4-ee

Activity

  1. JohnVillalovos commented on Nov 18, 2021

    Member

    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 []).

  2. skycaptain commented on Nov 18, 2021

    Author

    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.

    Hmm, having the same issue with two user ids:

    group_mrs = group.mergerequests.list(
        all=True,
        state="opened",
        author_id=423,
        approver_ids=[11, 423],
    )
    [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'
    
  3. JohnVillalovos commented on Nov 18, 2021

    Member

    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.

    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[]=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.

  4. JohnVillalovos commented on Nov 18, 2021

    Member

    I dug into this a bit more:

    So to fix this we need to send the arrays in the proper way.

  5. JohnVillalovos commented on Nov 18, 2021

    Member

    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.

  6. JohnVillalovos commented on Nov 19, 2021

    Member

    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_ids list. Not sure how the GitLab server will react to that...

  7. added 2 commits that reference this issue on Nov 20, 2021
    e3c2e95
    fdc854a
  8. JohnVillalovos commented on Nov 20, 2021

    Member

    @skycaptain #1699 is available which should resolve the issue. In my testing it is working to fix this issue.

  9. skycaptain commented on Nov 21, 2021

    Author
  10. JohnVillalovos commented on Nov 21, 2021

    Member

    @JohnVillalovos works!

    Awesome. Thank you for testing it @skycaptain !

  11. added 4 commits that reference this issue on Nov 27, 2021
    7b2ade3
    b44cef7
    902d9f6
    ec91760
  12. 26 remaining items

  13. added 2 commits that reference this issue on Feb 14, 2022
    215e0c6
    3244596
  14. added a commit that references this issue on Mar 10, 2022
    2bc7fad
  15. added 2 commits that reference this issue on Mar 26, 2022
    81d8c46
    f7e0842
  16. added 7 commits that reference this issue on Jul 24, 2022
    a939db1
    7f6a8c2
    50b1f12
    2ca7ddb
    ba084c6
    bc6ddf2
    1af44ce
  17. locked as resolved and limited conversation to collaborators on Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL