Skip to content

project-merge-request cancel-merge-when-pipeline-succeeds fails with gitlab.exceptions.GitlabMROnBuildSuccessError: 404: 404 Not Found #2349

Closed
@TheDJVG

Description

@TheDJVG

Description of the problem, including code/CLI snippet

When a pipeline is marked a merge on successful pipeline it seems this cannot be cancelled as the request is failing with a 404.

Running python-gitlab with -d shows that's it's doing a PUT:

DEBUG:urllib3.connectionpool:https://gitlab.<redacted>:443 "PUT /api/v4/projects/10/merge_requests/26/cancel_merge_when_pipeline_succeeds HTTP/1.1" 404 25
                                                           ^^^^^

The documentation however specfies a POST should be used: https://docs.gitlab.com/ee/api/merge_requests.html#cancel-merge-when-pipeline-succeeds

Expected Behavior

The request to merge is cancelled when pipeline succeeded.

Actual Behavior

# gitlab -v project-merge-request cancel-merge-when-pipeline-succeeds --project-id 10 --iid 26                    INT ✘ 
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/gitlab/exceptions.py", line 333, in wrapped_f
    return f(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/gitlab/v4/objects/merge_requests.py", line 188, in cancel_merge_when_pipeline_succeeds
    server_data = self.manager.gitlab.http_put(path, **kwargs)
  File "/usr/lib/python3.10/site-packages/gitlab/client.py", line 1067, in http_put
    result = self.http_request(
  File "/usr/lib/python3.10/site-packages/gitlab/client.py", line 798, in http_request
    raise gitlab.exceptions.GitlabHttpError(
gitlab.exceptions.GitlabHttpError: 404: 404 Not Found

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

Traceback (most recent call last):
  File "/usr/bin/gitlab", line 33, in <module>
    sys.exit(load_entry_point('python-gitlab==3.10.0', 'console_scripts', 'gitlab')())
  File "/usr/lib/python3.10/site-packages/gitlab/cli.py", line 377, in main
    gitlab.v4.cli.run(
  File "/usr/lib/python3.10/site-packages/gitlab/v4/cli.py", line 542, in run
    data = g_cli.run()
  File "/usr/lib/python3.10/site-packages/gitlab/v4/cli.py", line 81, in run
    return self.do_custom()
  File "/usr/lib/python3.10/site-packages/gitlab/v4/cli.py", line 102, in do_custom
    return getattr(class_instance, method_name)(**self.args)
  File "/usr/lib/python3.10/site-packages/gitlab/cli.py", line 71, in wrapped_f
    return f(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/gitlab/exceptions.py", line 335, in wrapped_f
    raise error(e.error_message, e.response_code, e.response_body) from e
gitlab.exceptions.GitlabMROnBuildSuccessError: 404: 404 Not Found

Specifications

  • python-gitlab version: 3.10.0
  • API version you are using (v3/v4): v4
  • Gitlab server version (or gitlab.com): 15.5.1 (but also observed on 15.3.3)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions