Inconsistency in Pull Request timeline events: Connected_Event

Title says it all. I’ve found some inconsistent behavior on the Connected_Event timeline item that I can’t really explain.

For context, I am trying to derive all issues referenced in a pull request. This can come in many forms:

  • in the body of the PR mentioning an issue
  • as a comment to the PR mentioning an issue
  • as a commit that is part of the PR that references an issue

In my search, I found this timeline event: CONNECTED_EVENT which I thought was the answer to most of my searching. However, the responses I’m getting back are a little inconsistent.

Take for example these two pull requests:


I ran this query:

query test {
   repository(owner: "metrumresearchgroup", name: "rbabylon") {
    pullRequest(number: ){
      title
      timelineItems(itemTypes: [CONNECTED_EVENT] last: 100){
        nodes {
          __typename
         ...on ConnectedEvent {
            subject {
              ...on Issue {
                title
                number
              }
            }
          }
        }
      }
    }
  }
}

on both these PR’s

When I run it on 104: I get back nothing. But looking at the PR, I see that ISSUE #91 is referenced in the body.

When I run it on 99, I get back Issue #92, which is referenced in the body?

Why am I getting different results?

:wave: @blackglade, thanks for posting this question! In context, this ConnectedEvent is actually part of the Linked issues feature described in this article about Linking a pull request to an issue - manually linking a pull request to an issue rather than the “association” that happens in an issue body or comment when cross-referencing a specific issue or pull request.

Explanation

I ran this query against PR #104 including the createdAt field scoped in the ConnectedEvent fragment:

query {
  repository(owner: "metrumresearchgroup", name: "rbabylon") {
    pullRequest(number: 104) {
      title
      timelineItems(itemTypes: [CONNECTED_EVENT], last: 100) {
        nodes {
          __typename
          ... on ConnectedEvent {
            createdAt # <= new!
            subject {
              ... on Issue {
                title
                number
              }
            }
          }
        }
      }
    }
  }
}

I noted its value:

              "createdAt": "2020-06-19T13:22:23Z",

Reviewing the timeline of metrumresearchgroup/rbabylon#99, I see that this particular event lines up with that createdAt value, which is different from the timestamp of the pull request body referencing the same pull request at 2020-06-18T20:54:32Z. I hope this helps!