Learning center

Why does GitHub report a pull request's mergeable state as unknown?

GitHub computes whether a pull request merges cleanly in the background, and starts the job when something reads the pull request. Until it finishes, mergeable is null and mergeable_state reads unknown. Treat that as "not computed yet": reread a few seconds later, and never let unknown stand for "no conflict".

What the API promises#

The get a pull request reference describes the mechanism. When you get, create or edit a pull request, GitHub creates a test merge commit against the base branch. The mergeable attribute reports whether that commit could be made, and it "can be true, false, or null. If the value is null, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request."

The REST guide's section on checking mergeability of pull requests turns that into a recipe: on the pull request webhook, call the get endpoint to start the job, then poll the same endpoint until mergeable is true or false.

Two consequences follow. First, the read that starts the job is the read most likely to see null. A tool that reads a pull request once, right after a push to the base branch, often gets the one answer that carries no information. Second, the computation is per base and head: every push to either side starts it again, so a busy base branch keeps sending open pull requests back to unknown.

mergeable_state is the companion string. The reference shows it only in its example response ("clean"), and the values a tool meets in practice include clean, blocked, behind, unstable, dirty and unknown. Only dirty means a conflict. unknown goes with mergeable: null and means the same thing: not computed yet.

The bug this causes#

The failure is a decision written as if state == "dirty": conflict else: no conflict. It reads naturally, and it is wrong for exactly one value. When the read lands on unknown, the else branch reports "no conflict" for a pull request that may conflict. A wait loop built on it reports success, or times out saying the branch "is not dirty", and the person reading the log does the wrong thing next.

Reading less often makes it worse, not better. A loop that reads every five minutes gives the background job plenty of time between reads, but any push to the base branch in that interval starts a new computation, and the next read can land on unknown again.

The lab#

The lab needs Python 3 and simulates GitHub's answers, so it runs without a network or a token. Each case is a sequence of answers that consecutive reads of one pull request returned in practice.

UNKNOWN = {"mergeable": None, "mergeable_state": "unknown"}
DIRTY = {"mergeable": False, "mergeable_state": "dirty"}
CLEAN = {"mergeable": True, "mergeable_state": "clean"}

def naive(read):
    return "conflict" if read()["mergeable_state"] == "dirty" else "no conflict"

def polled(read, sleep, rereads=3, delay=5):
    pr = read()
    for _ in range(rereads):
        if pr["mergeable"] is not None:
            break
        sleep(delay)
        pr = read()
    if pr["mergeable"] is None:
        return "not computed yet"
    return "conflict" if pr["mergeable"] is False else "no conflict"

def scripted(answers):
    it = iter(answers)
    return lambda: next(it)

waited = []
cases = {
    "unknown, clean": [UNKNOWN, CLEAN],
    "unknown, unknown, dirty": [UNKNOWN, UNKNOWN, DIRTY],
    "unknown x4": [UNKNOWN] * 4,
}
for name, answers in cases.items():
    waited.clear()
    a = naive(scripted(answers))
    b = polled(scripted(answers), waited.append)
    print(f"{name:26} naive={a:12} polled={b:17} waited={sum(waited)}s")
unknown, clean             naive=no conflict  polled=no conflict       waited=5s
unknown, unknown, dirty    naive=no conflict  polled=conflict          waited=10s
unknown x4                 naive=no conflict  polled=not computed yet  waited=15s

The naive check says "no conflict" in all three cases, and it is wrong in the second. The polled check finds the conflict after two rereads. In the third case it does not pretend: after 15 seconds it reports that GitHub has not computed an answer, and the caller decides what that means for it. A merge bot should not merge; a status line should say unknown.

To use the same function against the API, replace read with a call to GET /repos/{owner}/{repo}/pulls/{number} and sleep with time.sleep. Keep the stubbed version as the test.

Choose the reread budget#

Bound the rereads instead of polling until an answer arrives. Some pull requests stay unknown for a long time; a pull request waiting in a merge queue is a common one. A small budget, such as three rereads five seconds apart, resolves most reads and caps the extra wait at 15 seconds. Spend the budget only on unknown; every other value is an answer.

Carry the last state into your messages. "Timed out; merge state reads unknown" sends the reader to the pull request page. "Timed out; not dirty" sends them to the wrong conclusion.

Mind the rate limit. Each reread is a request against your token's or app's quota. If many pull requests are read in one pass, reread only the ones that answered unknown, as the production fix below does.

Finally, do not use mergeable as a merge decision on its own. It says whether the test merge commit could be made, not whether checks pass or reviews are in. If your branch rules require branches to be current, read about requiring up-to-date branches; if a merge queue runs your checks, the merge queue guide covers how its checks report.

In production#

In the case behind this guide, a script that waited for a pull request's checks decided "not dirty" from a single read of mergeable_state, taken once every five minutes. None of its reads came back dirty, so after ten minutes it gave up saying the pull request was not dirty while it conflicted with the base branch. A sample of 40 open pull requests, each read once, found 5 unknown. Read again seconds later, most resolved: one to clean, three to blocked within a minute. One stayed unknown, with mergeable: null, over 40 seconds of reads, and another read unknown on one pass and dirty on the next. The fix rereads an unknown state up to three times, five seconds apart, and names the last state it read when it gives up.

Where this came from#

Proofline found this in its own pull request tooling and changed that tooling on 18 November 2026; the change went out with that day's release. The sample of 40 pull requests and the reread budget above are from that change. Proofline reviews GitHub pull requests; new organizations get one calendar month of hosted code review without a cloud connection. Start a free GitHub review ยท Eligibility and fair-use terms

Questions#

How long does GitHub take to compute mergeability?

GitHub does not publish a figure. In the sample above most reads resolved within seconds to a minute, and some pull requests stayed unknown for longer, so bound the wait and report unknown when it runs out.

Does the pull_request webhook payload tell me whether it conflicts?

Do not rely on it. GitHub's own recipe answers the webhook by calling the get endpoint, which starts the computation, and then polling it, so treat a mergeable value in a payload as possibly out of date.

Is mergeable_state "blocked" a conflict?

No. blocked means branch rules, such as required reviews or checks, stop the merge. A conflict is dirty, with mergeable: false.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading