Skip to content

Invalid ref (`HEAD`) when querying blob info via GraphQL

Summary

Passing HEAD as a ref when querying for blob info via GraphQL (repository > blobs > nodes) results in a Ref is not valid error and as a result, the refactored blob viewer cannot be rendered.

Steps to reproduce

Via GraphQL explorer

query getBlobInfo($projectPath: ID!, $filePath: String!, $ref: String!) {
  project(fullPath: $projectPath) {
    repository {
      blobs(paths: [$filePath], ref: $ref) {
        nodes {
          id
          name
        }
      }
    }
  }
}
{
  "filePath": "package.json",
  "projectPath": "flightjs/Flight",
  "ref": "HEAD"
}

Via frontend

  1. Open a file via the repository files browser
  2. Replace the branch name in the URL with HEAD

Example Project

Example

What is the current bug behavior?

When passing HEAD in the ref query variable, the GraphQL response includes a Ref is not valid error.

What is the expected correct behavior?

When passing HEAD as ref, the GraphQL response should include the blob info.

Relevant logs and/or screenshots

{
  "data": {
    "project": {
      "repository": {
        "blobs": null
      }
    }
  },
  "errors": [
    {
      "message": "Ref is not valid",
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "path": [
        "project",
        "repository",
        "blobs"
      ]
    }
  ]
}
before after
Screenshot_2022-05-10_at_10.16.13 Screenshot_2022-05-10_at_10.16.32
Edited by Jacques Erasmus