API - Getting the reason that a pull request isn't mergeable?

I can use the pull requests api to see whether a PR is mergeable, and I can use the status api to check custom statuses logged for a given commit, but how can I fetch the reason that a PR is blocked from merging (e.g. it could be merge conflicts, review obligations, commit status)?

1 Like

There isn’t an API that summarizes why a PR is mergeable or not, only that it is or isn’t. In the documentation it states:

The value of the mergeable attribute can be true, false, or null. If the value is null, this means that the mergeability hasn’t been computed yet, and a background job was started to compute it. Give the job a few moments to complete, and then submit the request again. When the job is complete, the response will include a non-null value for the mergeable attribute.

We don’t record the result of why, only yes, no, or not yet computed.

I hope that helps :+1:

I also found the undocumented attribute mergeable_state, which gives a little more info: it can be clean, dirty, blocked, unstable, or unknown. It seems like dirty means merge conflicts, so that’s been granular enough for me for now.


1 Like