Skip to content

Querying repository by name with github.com prefix always returns empty string for name

Created by: felixfbecker

Run this GraphQL query on k8s.sgdev.org:

query {
  repository(name:"github.com/asdasd") {
    name
  }
}

API console link

You can use any repo name, as long as it starts with github.com/ (even just that string).

it returns this result:

{
  "data": {
    "repository": {
      "name": ""
    }
  }
}

An empty string should never be returned. A repo with an empty name obviously doesn't exist.

Interestingly, when you add other fields, you notice you can query for its id, but if you add e.g. createdAt or description those fields (not the repository field itself) fail with a "repo not found" error:

query {
  repository(name:"github.com/asdasd") {
    name
    id
    createdAt
    description
  }
}

Result:

{
  "data": {
    "repository": {
      "name": "",
      "id": "UmVwb3NpdG9yeTow",
      "createdAt": "2019-08-07T15:04:24Z",
      "description": null
    }
  },
  "errors": [
    {
      "message": "repo not found",
      "path": [
        "repository",
        "description"
      ]
    }
  ]
}

Note that the browser extension / native integrations do this query and interprets this result as the repo existing, which breaks code intelligence.

I cannot reproduce this with sourcegraph.com, so I suspect it only happens with certain external service configurations.