Skip to main content

How to Fix Looker Git Issues

While using Spectacles, you might occasionally encounter an error related to Git operations in Looker, like creating or checking out branches.

This error is a bug in Looker, where the the Spectacles Looker user's local Git repository in Looker becomes corrupted.

You can confirm this is the case by sudoing as the Spectacles Looker user and attempting to create a new branch.

You will see an error similar to the following:

git checkout failed: Host key verification failed.
fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
RETRY FAILED: 'jgit reset --hard' Invalid ref name: HEAD

The easiest way to fix this error is to recreate the Looker user used by Spectacles, adding the new Looker user as a Spectacles worker and deleting the old one. Here's how you should do it to avoid downtime in Spectacles:

Create a new Looker user

  1. In Looker, go to Admin > Users.
  2. Click Add Users.
  3. Make up an email address and untick Send setup emails.
  4. Assign the necessary roles and permissions. If you're unfamiliar with the minimum requirements, check our guide on how to create an API key in Looker. Or you can copy the role(s) of an existing Spectacles Looker user.
  5. Click Save.
  6. Click on the new Looker user.
  7. Under API Keys, click Edit Keys.
  8. Click New API Key.
  9. Note the Client ID and Client Secret of the new key.

Set up a new worker in Spectacles

  1. In Spectacles, click ⚙️ and scroll down to the Workers section.
  2. Add a new worker using the client ID and secret you just created.

Delete the corrupted worker

Each worker corresponds to an individual Looker user. The ID of each worker matches the client ID of that Looker user's API key.

You need to delete the pre-existing worker that corresponds to the corrupted Looker user so no Spectacles runs will use it.

If there is only one pre-existing worker:

  1. Note the worker's ID, which you will use to identify the Spectacles Looker user.
  2. Delete the worker.

If there are multiple pre-existing workers:

You'll need to figure out which worker has the Git issue. Reach out to our support team to help you identify the corrupted one.

If you'd rather do it yourself, follow these steps:

  1. Note the IDs of each Spectacles worker.
  2. In Looker, find the Looker users with API key client IDs that match the IDs from Step 1. There is an API endpoint that can help you do this quickly if you have many users to search through.
  3. Sudo as each matching Looker user and try to check out a Git branch. This will help you identify which user has the Git issue.
  4. Note the Client ID of the API key associated with that Looker user. It will match the ID of the corrupted worker in Spectacles.

Delete the corrupted Looker user

  1. In Looker, go to Admin > Users.
  2. Find the Looker user whose API key's client ID matches the ID of the corrupted worker. There is an API endpoint that can help you do this quickly if you have many users to search through.
  3. Click on the corrupted Looker user.
  4. Click Delete.

New Spectacles runs will use the freshly created worker and Looker user, which will solve this error.