Null mergeCommit merged PR object - when does that happen?


#1

Hi,

I’m using the GraphQL API and I don’t understand under which circumstances the mergeCommit field of a merged PR object is null. The documentation here doesn’t explain it either.

This seems to happen on open-source repos mostly, so I’m thinking that it might have something to do with it. I tried reproducing this behaviour with various forking/merging workflows unsuccessfully.

For example, running this query on the Ruby on Rails repository will return a merged PR with a null mergeCommit even though a merge commit can be seen on the PR’s page.

query { 
  repository(owner: "rails" name: "rails") {
    name
    pullRequest(number: 18074) {
      number
      state
      mergeCommit {
        id
      }
    }
  }
}

Could you provide a set of circumstances under which a merged PR will have a null mergeCommit?

Thanks,

Matt


#2

Hi @matthieualouis!

Interesting! It looks like the REST API call returns a merge_commit_sha as well, which appears to be 3eeee85b954d1a36f1383efc47702b608e06087a. Attempting to view that commit in the GitHub UI returns a 404: https://github.com/rails/rails/commit/3eeee85b954d1a36f1383efc47702b608e06087a - likely because history was rewritten at some point, and that commit no longer exists. Instead of give a SHA with no information, the GraphQL API will return a null.

If you have any other examples, please don’t hesitate to share so that I can dig in!