Gracefully handle corrupted/invalid repo HEAD
What does this MR do and why?
Closes #432019 (closed)
Problem
If the repository is corrupted and the default branch points to a missing commit, then it is not possible to see any information about the project.
Solution
Handle an exception on project page and display a helpful error message.
Screenshots or screen recordings
How to set up and validate locally
- Create a new project with a README file
- In Rails console execute and get a path to the repository
> Project.last.repository
=> #<Repository:@hashed/8e/61/8e612bd1f5d132a339575b8dafb7842c64614e56bcf3d5ab65a0bc4b34329407>
- From GDK folder execute (use the path from step 2 + ".git" at the end)
cd gitlab-development-kit
praefect -config gitaly/praefect.config.toml metadata -virtual-storage default -relative-path @hashed/8e/61/8e612bd1f5d132a339575b8dafb7842c64614e56bcf3d5ab65a0bc4b34329407.git
Example response
...
Replica Path: "@cluster/repositories/fc/72/415"
...
- Go to replica path folder
cd repositories/@cluster/repositories/fc/72/415
- Break the default branch of the repository
echo "aaa" > refs/heads/main
- Drop repository caches in Rails console
Project.last.repository.expire_all_method_caches
- Visit the project page, it should be broken
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Vasilii Iakliushin