Problem Merging Pull Requests


#1

Is merging pull request functionality properly supported for GitHub apps?

i.e. PUT /repos/:owner/:repo/pulls/:number/merge

The existence of this topic implies it is: Pull requests open after merge

However, Pull Request merging is not explicitly listed under Available Endpoints here: https://developer.github.com/v3/apps/available-endpoints/

My app is receiving a response of 405 Method Not Allowed but not with the error message “Pull Request is not mergeable” as mentioned in https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button

Note: same code works fine if used with a Personal Access Token


#2

My app has Read & write access to “Contents” and “Pull Requests”. Here’s a debug of the permissions for the particular installation I’m trying with: "permissions":{"contents":"write","pull_requests":"write","metadata":"read","statuses":"read"}

I found a reference to merging here: https://developer.github.com/v3/apps/permissions/#permission-on-contents

It’s listed as PUT /repositories/:repository_id/pulls/:id/merge instead of PUT /repos/:owner/:repo/pulls/:number/merge


#3

I have resolved this - it was unrelated to any Merge permissions. The root cause happened to be that the allow_xxxxxx merge flags are not being provided in the repo JSON and hence an incorrect type of PR merge was being attempted.


#4

Thanks for letting us know that you resolved this, @rarkins :+1:

For any future reports like these, please include curl -v outputs (https://curl.haxx.se/) or equivalent logs (full HTTP request and response pairs, including all headers and bodies) for API calls which clearly demonstrate the behavior you describe. It’s often hard to provide advice and investigate without those details (i.e. with just a general description of the problem), so it’d be helpful you could provide those. Just make sure authentication credentials are masked in curl -v or the logs. :v:


#5

Seeing as it’s on-topic, there does still seem to exist a problem with GitHub Apps merging Pull Requests. It happens only on Organizations when the “Restrict who can push to this branch” setting is enabled. In short: there’s no way to give an app permission to push, so if this setting is enabled, GitHub Apps cannot perform Pull Request merges.


#6

Thank you @rarkins, we’ll investigate.