Shared group members not returned
Summary
Report does not return any shared group members.
Steps to reproduce
Create Group 1
- Invite Member1 into group 1
- Create Project A within group 1
Create Group 2
- Create Project B within group 2
- Share with Group 2 with Group 1
Outcome:
- Group 1 is shared group member of Group 2, Member1 is a member of Group 1, so they have access to Projects A and B
- The report does not show the shared group membership of Group 2.
- The report does show Member1 has a shared membership for Project C.
Relevant Logs and Code
shared_with_groups
attribute does not exist for group object:
After #L111, print(group.attributes)
return the following without shared_with_groups
:
{'id': 6, 'web_url': 'https://[redacted].gcp.gitlabsandbox.net/groups/group1', 'name': 'group1', 'path': 'group1', 'description': '', 'visibility': 'private', 'share_with_group_lock': False, 'require_two_factor_authentication': False, 'two_factor_grace_period': 48, 'project_creation_level': 'developer', 'auto_devops_enabled': None, 'subgroup_creation_level': 'maintainer', 'emails_disabled': None, 'mentions_disabled': None, 'lfs_enabled': True, 'default_branch_protection': 2, 'default_branch_protection_defaults': {}, 'avatar_url': None, 'request_access_enabled': True, 'full_name': 'group1', 'full_path': 'group1', 'created_at': '2023-10-10T05:57:53.368Z', 'parent_id': None, 'shared_runners_setting': 'enabled', 'ldap_cn': None, 'ldap_access': None, 'marked_for_deletion_on': None, 'wiki_access_level': 'enabled', 'repository_storage': None}
Could be related to this where:
Fetching a list of objects does not always include all attributes in the objects. To retrieve an object with all attributes, use a get() call.
get(object.id)
call doesn't seem to work
After the same line, I tried to run print(group.get(group.id))
which is also used in the test and got the following error which seems contradicting:
Traceback (most recent call last):
File "/Users/daphne/gitlab-group-member-report/group_member_report.py", line 332, in <module>
reporter = Group_Member_Reporter(args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/daphne/gitlab-group-member-report/group_member_report.py", line 73, in __init__
self.make_group_share_map()
File "/Users/daphne/gitlab-group-member-report/group_member_report.py", line 114, in make_group_share_map
print(group.get(group.id))
^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/gitlab/base.py", line 134, in __getattr__
raise AttributeError(message)
AttributeError: 'Group' object has no attribute 'get'
<class 'gitlab.v4.objects.groups.Group'> 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.14.0/faq.html#attribute-error-list
Zendesk ticket (internal only)
Edited by Daphne Kua