-
Notifications
You must be signed in to change notification settings - Fork 668
ProjectMergeRequest.merge fails because of incorrect request behaviour #1120
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
Comments
I've already created a branch locally, but I have no rights to push a new branch, sadly. |
@ferhat-aram Python-gitlab is just a wrapper around the GitLab API. I can't help you with your permission issues. |
Yeah I know that, but the Wrapper itself does this and not the GitLab API -> The GitLab API works completley fine here. I already tested it several times via curl and as I already said, I fixed it locally by changing the handling of the So the problem here relates to the wrapper itself and not the actual API. |
This problem isn't something new. I've got to do that, after it was broken for several months. I guess the GitLab API changed at one time and the wrapper wasn't updated accordingly to those API changes. |
Ah yes. You can fork the project and create a merge request: https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request |
What's weird is that this works for me as is, currently. I have pipelines with scripts using this from today where I've had no issues. Example (I have no idea why GitLab provides both mr = downstream.mergerequests.create({'source_branch': source_branch,
'target_branch': target_branch,
'assignee_id': assignee,
'title': title,
'description': description,
'remove_source_branch': 'true'
})
time.sleep(10) # wait for sidekiq
print('[Info] Applying MR merge settings..')
mr.merge(should_remove_source_branch=True,
merge_when_pipeline_succeeds=True) So I'm wondering - are you getting this consistently on a clean open MR (previous API calls can affect that)? can you post the code and the logs? You can get 405 for a bunch of reasons (Work in Progress, Closed, Pipeline Pending Completion, or Failed while requiring Success). I've also seen this when I try to apply the merge too quickly after creation (hence the hardcoded wait above). I'll check if my existing project config or the |
The request generally doesn't work for me with post data. I tried it several times. What GitLab version do you use? |
I just tried this on gitlab.com (13.1.0-pre) on an open MR with an in-progress pipeline, and this works (merge is set for after pipeline succeeds and branch is set for deletion, and the MR is eventually merged).
I also tried the curl call without the data and got a 405 response (with the project configured to require pipelines to succeed before merge). That's why I was wondering if your API calls were hitting one of the conditions that trigger 405 as described above. But maybe this fixes some other quirks, like reverse proxies that mess with request bodies or something. |
Since the PR was merged I guess this can be closed :) |
Problem
When I'm trying to merge a merge request via the ProjectMergeRequest.merge function and with "should_remove_source_branch" and/or "merge_when_pipeline_succeeds", I get the HTTP Code
405
with the messageMethod not allowed
back.Expected Behavior
I tried to do a API-Call as explained here https://docs.gitlab.com/ee/api/merge_requests.html#accept-mr and it works.
Using curl and sending a put request to
/projects/:id/merge_requests/:merge_request_iid/merge?remove_source_branch=True
worked fine.Actual Behavior
The problem here is, that pythlon_gitlab merge API doesn't generate a query string, but send the paramters as post_data, which isn't accepted by the GitLab API.
I tried a curl request with
"Content-type: application/json" -d '{"merge_when_pipeline_succeeds": "True"}'
and/projects/:id/merge_requests/:merge_request_iid/merge
and the request failed.It's very clear, that the request itself isn't done properly as expected (File :
gitlab/v4/objects.py
The code handles those two parameters as post_data, while it should handle them as query_data:
gitlab/init.py
Specifications
The text was updated successfully, but these errors were encountered: