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
- In Looker, go to Admin > Users.
- Click Add Users.
- Make up an email address and untick Send setup emails.
- 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.
- Click Save.
- Click on the new Looker user.
- Under API Keys, click Edit Keys.
- Click New API Key.
- Note the Client ID and Client Secret of the new key.
Set up a new worker in Spectacles
- In Spectacles, click ⚙️ and scroll down to the Workers section.
- 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:
- Note the worker's ID, which you will use to identify the Spectacles Looker user.
- 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:
- Note the IDs of each Spectacles worker.
- 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.
- 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.
- 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
- In Looker, go to Admin > Users.
- 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.
- Click on the corrupted Looker user.
- Click Delete.
New Spectacles runs will use the freshly created worker and Looker user, which will solve this error.