Skip to content
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

GitLab merge bad HTTP request parsing of arguments #384

Closed
ferhat-aram opened this issue Jun 19, 2020 · 2 comments
Closed

GitLab merge bad HTTP request parsing of arguments #384

ferhat-aram opened this issue Jun 19, 2020 · 2 comments
Assignees
Labels

Comments

@ferhat-aram
Copy link

ferhat-aram commented Jun 19, 2020

When I tried to use the automatic merging, when the pipeline succeeds and after that deleting the source branch, I run into problems, as the HTTP request is not allowed.

This issue relates to the library itself and I also already created an issue there https://github.com/python-gitlab/python-gitlab/issues/1120.

Nevertheless the problem would still remain here partly, when using the argument to remove the branch after a successful merge.

This is because the method references the wrong parameter for the option to remove the source branch afterwards, as you see here:

pyup/pyup/providers/gitlab.py

    def _merge_merge_request(self, mr, config):
        mr.merge(remove_source_branch=config.gitlab.should_remove_source_branch,
                 merge_when_pipeline_succeeds=True)

Even though the methods accept this as a valid paramaeter because of **kwargs, this wouldn't parse the given argument correctly as a query_data (this is the issue in the python-gitlab library itself but will lead after the fix to issues here):

gitlab/v4/objects.py

 def merge(
        self,
        merge_commit_message=None,
        should_remove_source_branch=False,
        merge_when_pipeline_succeeds=False,
        **kwargs
    ):

      path = "%s/%s/merge" % (self.manager.path, self.get_id())
        data = {}
        if merge_commit_message:
            data["merge_commit_message"] = merge_commit_message
        if should_remove_source_branch:
            data["should_remove_source_branch"] = True
        if merge_when_pipeline_succeeds:
            data["merge_when_pipeline_succeeds"] = True
        server_data = self.manager.gitlab.http_put(path, post_data=data, **kwargs) 
        self._update_attrs(server_data)

Here the arguments are currently parsed as "post_data", which is simply wrong in the python-gitlab library itself, as I already explained several times. After my pull request there would be accepted though, the argument wouldn't be handled as "should_remove_source_branch", but as a **kwargs, since the naming "remove_source_branch" is simply wrong.

I'll do a pull request if you would allow me to do so, as I already fixed that locally.

@ferhat-aram
Copy link
Author

ferhat-aram commented Jun 19, 2020

The python-gitlab version should be updated to the latest version, as the fix for that problem python-gitlab issue will come with the latest version.

@rafaelpivato rafaelpivato self-assigned this Dec 27, 2020
@rafaelpivato
Copy link
Contributor

Let me know if this was not fixed with your PR. Thanks for all that work, @ferhat-aram !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants