Cannot return null for non-nullable field CommitComment.commit


#1

Hello, I’m getting this error in many repositories.
This error is thrown because I try to connect to the commit.

Actually, I have seen errors like this one for stargazers, commits, etc …
What can I do to avoid problems like that?
I’m asking because I am a researcher and have a few scripts that rely on API v3, but on v4 I have much more information that could help me a lot.

Query:

query($owner:String!, $repo:String!, $after:String) {
    repository(owner: $owner, name: $repo) {
      commitComments(first: 100, after: $after) {
        pageInfo {
          hasNextPage
          endCursor
        }
        comments:nodes {
          author {
            ... on User { id:databaseId }
            ... on Organization { id:databaseId }
            login
            type:__typename
          }
          author_association:authorAssociation
          body
          commit { sha:oid }
          created_at:createdAt
          created_via_email:createdViaEmail
          id:databaseId
          editor {
            ... on User { id:databaseId }
            ... on Organization { id:databaseId }
            login
            type:__typename
          }
          last_edited_at:lastEditedAt
          path
          position
          published_at:publishedAt
          reaction_groups:reactionGroups {
            content
            created_at:createdAt
            users { total_count:totalCount }
          }
          updated_at:updatedAt
        }
      }
    }
  }

Parameters:
{"owner":"nodejitsu","repo":"node-http-proxy"}
{"owner":"facebook","repo":"prepack"}
{"owner":"zurb","repo":"foundation-sites"}
{"owner":"jashkenas","repo":"underscore","after":"Y3Vyc29yOnYyOpHOABTbug=="}
{"owner":"socketstream","repo":"socketstream"}
{"owner":"flatiron","repo":"director"}
{"owner":"npm","repo":"npm"}
{"owner":"mozilla","repo":"pdf.js"}
{"owner":"avajs","repo":"ava"}
{"owner":"facebook","repo":"react","after":"Y3Vyc29yOnYyOpHOAHJXBw=="}
(and others)


Cannot return null for non-nullable field ReviewRequestedEvent.subject
#2

Hi @hsborges!

The best thing you can do is to continue to report these as bugs to GitHub! I’m able to easily reproduce these on my end, and I’m in the process of writing up an internal bug report.

I’ll update this issue as soon as I have more information - thank you a ton for the feedback, and I’m very hopeful we can get this fixed for you soon!


#3

Hi @hsborges!

I went ahead and made a fix, all of the queries you linked to are now working for me in production.

The issue is that commit comments are “lost” to the world when the commit they are attached to is no longer in git history (because someone or something overwrote it). These comments are not surfaced at all in the GitHub UI, but you can still pull them up via the API (both REST and GraphQL).

In the REST API, those Commit Comments have a link to the commit that returns a 404, but in GraphQL the commit connection needs to have a ‘real’ commit to function. In order to get around this, we have allowed the commit connection to be null, which is what you’ll see when you query for commit comments that are attached to nonexistent commits.

If any of this looks/sounds wrong, or if you run into this issue somewhere else, please don’t hesitate to let me know!

Thanks again for reporting this (and others)!


#4

Hi @nickvanw, thank you for fixing this :grinning:
This time I didn’t found any errors.