1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #8744 closed

500 error when trying to merge pull request via api (BB-9966)

Dan Falk
created an issue

When trying to POST to the pull request merge endpoint in the 2.0 API, I get the error message below.

This is even after supplying all optional parameters, including the message.

{"error": {"message": "name, email or commit message not provided", "detail": "  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/piston/resource.py\", line 198, in __call__
    result = checked_meth(request, *args, **kwargs)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/piston/resource.py\", line 185, in checked_meth
    return meth(*args, **kwargs)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/newrelic-2.8.0.7/newrelic/hooks/component_piston.py\", line 33, in __call__
    return self._nr_wrapped(*args, **kwargs)
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/bb/decorators.py\", line 38, in wrap
    return f(request, *a, **kwa)
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/bb/decorators.py\", line 374, in wrapped_function
    return func(*args, **kwargs)
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/api/v10/decorators.py\", line 78, inwrapped_function
    return func(*args, **kwargs)
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/api/v10/decorators.py\", line 206, in wrapper
    return f(self, request, *args, **kwargs)
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/api/decorators.py\", line 35, in wrapper
    val = func(self, request, *args, **kwargs)
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/pullrequests/api/v20/handlers.py\", line 280, in create
    return form.save()
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/pullrequests/forms.py\", line 626, in save
    self._merge()
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/pullrequests/forms.py\", line 593, in _merge
    closebranch=self.instance.close_anchor_branch)
  File \"/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/compare/merge.py\", line 36, in merge
    destinationhead=destcset)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/git.py\", line 1424, in merge
    fastforward=fastforward)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py\", line 494, in pull
    fastforward=fastforward)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py\", line 546, in fetchandmerge
    localmarker=localmarker, remotemarker=remotemarker, force=force)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py\", line 581, in _fetchandmerge
    localmarker=localmarker, remotemarker=remotemarker)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py\", line 463, in merge
    date)
  File \"/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py\",line 196, in commit
    raise CommitError('name, email or commit message not provided')
", "id": "b8be3ee85e344122846216e32755360a"}}

Comments (8)

  1. hadi khosrojerdi

    Dan Falk , you need to "message" parameter in the body request.

    This code work for me.

    .

    <?php 
    global $WP_Bucket;
    
    $response = $WP_Bucket->api("2.0/repositories/{owner}/{repo_slug}/pullrequests/{id}/merge/", "POST", array(
            "template" => array(
                            "owner"     =>  "hadi_",
                            "repo_slug" =>  "public_repository",
                            "id"         => 4
                        ),
            "body"    => json_encode( array(
                            "message" => "my message"
                        ))
        ));
    
    ?>
    
  2. Daniel Falk

    Thanks Hadi, although I mentioned that I was providing all optional parameters, including "message". But maybe it was a temporary error, or maybe I was somehow mistaken as to what I was passing. Either way, it if works for you, it is probably not an issue any longer.

  3. hadi khosrojerdi

    Daniel Falk , your welcome.

    when i try above code without "message" parameter ( or with empty value ). I get the error like your error.

    error-500-merge-pullrequest.png

    name, email or commit message not provided
    File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/piston/resource.py", line 198, in __call__ result = checked_meth(request, *args, **kwargs) File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/piston/resource.py", line 185, in checked_meth return meth(*args, **kwargs) File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/newrelic-2.12.0.10/newrelic/hooks/component_piston.py", line 33, in __call__ return self._nr_wrapped(*args, **kwargs) File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/bb/decorators.py", line 38, in wrap return f(request, *a, **kwa) File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/bb/decorators.py", line 374, in wrapped_function return func(*args, **kwargs) File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/api/v10/decorators.py", line 78, in wrapped_function return func(*args, **kwargs) File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/api/v10/decorators.py", line 206, in wrapper return f(self, request, *args, **kwargs) File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/api/decorators.py", line 35, in wrapper val = func(self, request, *args, **kwargs) File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/pullrequests/api/v20/handlers.py", line 280, in create return form.save() File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/pullrequests/forms.py", line 626, in save self._merge() File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/pullrequests/forms.py", line 593, in _merge closebranch=self.instance.close_anchor_branch) File "/opt/python/domains/bitbucket.org/2013-07-25/bitbucket/../bitbucket/apps/compare/merge.py", line 36, in merge destinationhead=destcset) File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/git.py", line 1424, in merge fastforward=fastforward) File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 490, in pull fastforward=fastforward) File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 542, in fetchandmerge localmarker=localmarker, remotemarker=remotemarker, force=force) File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 571, in _fetchandmerge (destcset, incomingcset), user, text, date) File "/opt/python/domains/bitbucket.org/current/bitbucket/local/env/lib/python2.7/site-packages/orochi/_gitmerge.py", line 192, in commit raise CommitError('name, email or commit message not provided')
    
  4. james young

    Here is a node example, using request, that I got working, based on the information that hadi khosrojerdi provided.

    This example is doing some things only because it is an example. In a real app you would probably want to pass in some data to pull the owner, repository name, pull request id, source branch name, authentication, etc.

    function mergePullRequest() {
        var options = {
                /* 10 seconds */
                timeout: 1000 * 10,
    
                /* `:owner`, `:repository`, and `:id` need to be valid values */
                url: 'https://bitbucket.org/api/2.0/repositories/:owner/:repository/pullrequests/:id/merge',
                auth: {
                    user: 'valid user with write access to repository',
                    pass: 'password for above user'
                },
                json: {
                    /* in a real app, you will want a more descriptive commit message here */
                    message: 'Merge in feature branch'
                }
            };
    
        request.post(options, function (error, response, body) {
            if (!error && response.statusCode === 200) {
                console.log(body);
            } else if (error) {
                /*
                 * When the HTTP POST is unsuccessful.
                 * An example would be if the url above was not valid.
                 */
                console.error(error.message);
            } else {
                /*
                 * When the HTTP POST is successful but the API returns an error.
                 * An example would be if there is a conflict.
                 */
                console.error(body.error);
            }
        });
    }
    

    Since this API call is actually working, I think the problem here is that the documentation on https://confluence.atlassian.com/display/BITBUCKET/pullrequests+Resource needs to be updated.

  5. Log in to comment