Skip to content

Can't manage GitLab Group attributes : membership_lock or shared_runners_setting #1431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Stan0304 opened this issue Apr 30, 2021 · 2 comments · Fixed by #1438
Closed

Can't manage GitLab Group attributes : membership_lock or shared_runners_setting #1431

Stan0304 opened this issue Apr 30, 2021 · 2 comments · Fixed by #1438
Labels

Comments

@Stan0304
Copy link

Stan0304 commented Apr 30, 2021

Description of the problem, including code/CLI snippet

I tried to update a GitLab group and I can't update or even read the following attributes even if those settings exists on the API side (https://docs.gitlab.com/ee/api/groups.html#update-group):

  • membership_lock
  • shared_runners_setting

Bellow the code to reproduce the error.

#!/usr/bin/env python3
import gitlab
import os

gl = gitlab.Gitlab('https://gitlab.com', private_token=os.environ['GITLAB_TOKEN'])
gl.auth()

# Load a gitlab group
group_id = 123456 # TODO use an existing group_id here
gitlab_group = gl.groups.get(group_id)

# show the request_access_enabled -> that call is OK
print('request_access_enabled', gitlab_group.request_access_enabled)

# show the membership_lock -> that call is NOT OK
print('membership_lock', gitlab_group.membership_lock)

# show the shared_runners_setting -> that call is NOT OK
print('shared_runners_setting', gitlab_group.shared_runners_setting)

The membership_lock attribute seems to be implemented, but the shared_runners_setting does not appear at all.

Expected Behavior

Having the ability to read and/or update the membership_lock and shared_runners_setting attributes of GitLab groups.

Actual Behavior

Actually when I try to read the membership_lock or shared_runners_setting, I get a AttributeError

request_access_enabled False # <- the first call that works
Traceback (most recent call last):
  File "/home/speyssard/.local/lib/python3.6/site-packages/gitlab/base.py", line 77, in __getattr__
    return self.__dict__["_updated_attrs"][name]
KeyError: 'membership_lock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/speyssard/.local/lib/python3.6/site-packages/gitlab/base.py", line 80, in __getattr__
    value = self.__dict__["_attrs"][name]
KeyError: 'membership_lock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/speyssard/.local/lib/python3.6/site-packages/gitlab/base.py", line 100, in __getattr__
    return self.__dict__["_parent_attrs"][name]
KeyError: 'membership_lock'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    print('membership_lock', gitlab_group.membership_lock)
  File "/home/speyssard/.local/lib/python3.6/site-packages/gitlab/base.py", line 102, in __getattr__
    raise AttributeError(name)
AttributeError: membership_lock

Specifications

  • python-gitlab version: 2.7.1 (and 2.5.0)
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 13.9.4-ee (not tested on gitlab.com but on a private gitlab server)
@nejch
Copy link
Member

nejch commented Apr 30, 2021

Hi @Stan0304, the get() calls return whatever the GitLab server returns.

In your case, membership_lock and shared_runners_setting are only available as a parameter for the POST and PUT request (create or update group), not for GET, at least according to https://docs.gitlab.com/ee/api/groups.html. You can verify this with a curl GT request, it will likely not show up in the json either.

This seems like an oversight in the GitLab's API, so I suggest you open an issue upstream and link it here https://gitlab.com/gitlab-org/gitlab.

It's true the shared_runners_setting is not in our list (so I'll keep this open) but that is mostly used for the CLI, if you pass the params as a dict to the update() or create() methods you should be able to use the params already. You will just not be able to later retrieve them via get().

@nejch nejch added the upstream label Apr 30, 2021
@Stan0304
Copy link
Author

That's right ! membership_lock does not appear for the GET. I did update membership_lock successfuly (as long as I do not try to read it first).
Thanks !

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants