Skip to content

gitlab project-merge-request-approval-rule list throws a KeyError "approval_rule_id" error. #2065

@MaximeCheramy

Description

@MaximeCheramy

Description of the problem, including code/CLI snippet

$ gitlab project-merge-request-approval-rule list --mr-iid 1 --project-id foo/bar

Expected Behavior

A list of approval rules

Actual Behavior

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/gitlab/base.py", line 107, in __getattr__
    return self.__dict__["_updated_attrs"][name]
KeyError: 'approval_rule_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/gitlab/base.py", line 110, in __getattr__
    value = self.__dict__["_attrs"][name]
KeyError: 'approval_rule_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/gitlab/base.py", line 130, in __getattr__
    return self.__dict__["_parent_attrs"][name]
KeyError: 'approval_rule_id'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/gitlab", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/dist-packages/gitlab/cli.py", line 362, in main
    gitlab.v4.cli.run(gl, what, action, args_dict, verbose, output, fields)
  File "/usr/local/lib/python3.9/dist-packages/gitlab/v4/cli.py", line 515, in run
    printer.display_list(data, fields, verbose=verbose)
  File "/usr/local/lib/python3.9/dist-packages/gitlab/v4/cli.py", line 483, in display_list
    self.display(get_dict(obj, fields), verbose=verbose, obj=obj)
  File "/usr/local/lib/python3.9/dist-packages/gitlab/v4/cli.py", line 461, in display
    id = getattr(obj, obj._id_attr)
  File "/usr/local/lib/python3.9/dist-packages/gitlab/base.py", line 146, in __getattr__
    raise AttributeError(message) from exc
AttributeError: 'ProjectMergeRequestApprovalRule' object has no attribute 'approval_rule_id'

<class 'gitlab.v4.objects.merge_request_approvals.ProjectMergeRequestA
pprovalRule'> was created via a list() call and only a subset of the
data may be present. To ensure all data is present get the object
using a get(object.id) call. For more details, see:

https://python-gitlab.readthedocs.io/en/v3.5.0/faq.html#attribute-error-list

Specifications

  • python-gitlab version: 3.5.0
  • API version you are using (v3/v4): not sure, the default one
  • Gitlab server version (or gitlab.com): 14.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions