Skip to content

project-push-rules delete broken #2941

@skycaptain

Description

@skycaptain

Description of the problem, including code/CLI snippet

I'm trying to delete a project push rule, but it results in a KeyError.

$ gitlab project-push-rules delete --project-id 1234
Traceback (most recent call last):
  File "/Users/[redacted]/.local/bin/gitlab", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/[redacted]/.local/pipx/venvs/python-gitlab/lib/python3.12/site-packages/gitlab/cli.py", line 418, in main
    gitlab.v4.cli.run(
  File "/Users/[redacted]/.local/pipx/venvs/python-gitlab/lib/python3.12/site-packages/gitlab/v4/cli.py", line 588, in run
    data = g_cli.run()
           ^^^^^^^^^^^
  File "/Users/[redacted]/.local/pipx/venvs/python-gitlab/lib/python3.12/site-packages/gitlab/v4/cli.py", line 79, in run
    return getattr(self, method)()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/[redacted]/.local/pipx/venvs/python-gitlab/lib/python3.12/site-packages/gitlab/v4/cli.py", line 181, in do_delete
    id = self.args.pop(self.cls._id_attr)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: None

I can get the project push rule successfully using gitlab -o json project-push-rules get --project-id 1234, so the rule exists and my token works.

Expected Behavior

No error, project rule gets deleted.

Actual Behavior

KeyError. See above.

Specifications

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

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