Skip to content

sudo should be remembered for SaveMixin objects #532

Closed

Description

@JonathonReinhart

Description of the problem, including code/CLI snippet

grp = gl.groups.get('example-group')

notif = grp.notificationsettings.get(sudo=otheruser)
print("Old level:", notif.level)

notif.level = gitlab.const.NOTIFICATION_LEVEL_GLOBAL
notif.save()    # missing sudo=otheruser

notif = grp.notificationsettings.get(sudo=otheruser)
print("New level:", notif.level)

Expected Behavior

I would expect this to change the notification level for the sudo'd user.

Actual Behavior

When I call notif.save(), it has seemingly no effect, because I am missing sudo.

Instead, the changes were applied to my admin account!

Changing the code to notif.save(sudo=otheruser) works as expected.

Specifications

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

Proposal

If an object is acquired using sudo=user, perhaps the library can attach that sudo user to the SaveMixin object, and automatically apply it when .save() is called without arguments.

I consider this a bug, and I can't imagine that anyone is actually relying on the current behavior.

Activity

  1. gpocentek commented on Jun 22, 2018

    @gpocentek
    Contributor

    Hi @JonathonReinhart

    I agree that this is an unexpected behaviour. I'm still trying to find the proper way to handle this in the code but I'll come up with something (not in the 1.5.0 release though).

  2. github-actions commented on Jul 12, 2024

    @github-actions

    This issue was closed because it has been marked stale for 15 days with no activity. If this issue is still valid, please re-open.

  3. JonathonReinhart commented on Jul 12, 2024

    @JonathonReinhart
    ContributorAuthor

    I believe this is still appropriate.

  4. reopened this on Jul 13, 2024
  5. JohnVillalovos commented on Jul 13, 2024

    @JohnVillalovos
    Member

    I'm not sure if I agree with the premise of this issue. As python-gitlab is a wrapper around the GitLab API. I'm not sure that I think it should be making decisions to save the sudo state. But that is just my opinion.

    Also this issue was opened over six years ago and nobody has felt motivated enough to do the work to create a PR to close this issue, which makes me think this should be closed.

  6. added 2 commits that reference this issue on Jul 13, 2024
    21f8d10
    b5fb1b8
  7. added 3 commits that reference this issue on Jul 15, 2024
    c70796f
    ae8b093
    9fe6b9f
  8. added a commit that references this issue on Jul 15, 2024
    d509da6
  9. locked as resolved and limited conversation to collaborators on Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions