Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does GitHub API return an unknown mergeable_state in a pull request?

From time to time, when I get a single pull requests from the GitHub API the response contains the following attributes found in the JSON response:

  "merged": false,
  "mergeable": null,
  "mergeable_state": "unknown",
  "merged_by": null,

Why is that? How can I figure out if this pull request is mergeable or not? Do I really need to reload the pull request until I get a different response?

like image 479
matv Avatar asked Jun 03 '15 12:06

matv


2 Answers

From one of the guys at GitHub:

The null value means that the mergeability of the pull request hasn't been computed yet. Mergeability is computed on demand and in the background, so when you fetch a pull request for which the mergeability isn't known -- you get back a null value but also a job is kicked off to compute the mergeability. If you make another request, you should see a non-null value for the mergeable attribute.

I guess implementing delayed retries is the way to go.

like image 191
matv Avatar answered Nov 15 '22 16:11

matv


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.

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

I hope that helps 👍

like image 1
Bajaj_Dk Avatar answered Nov 15 '22 15:11

Bajaj_Dk