Skip to content

config/locator: Improve error reporting for invalid repositories

The config.Locator structure optionally verifies whether a repository path maps to a valid Git repository, which helps us to get better error reporting when trying to execute Git commands in repositories that don't actually exist or which are corrupt.

But the error reporting in this function is quite lacking as we use IsGitRepository(), which only gives us a boolean to indicate whether the path corresponds to a Git repository that is indeed a valid. Consequentially, all we were able to report in this case was that the repository is missing.

This MR refactors our errors regarding missing or invalid repositories to be shared across Praefect and Gitaly. These shared errors are then used to replace IsGitRepository() with ValidateRepository(), which provides more detailed error reporting in the case where the path does not point to a valid repository. We can thus now report detailed information to the caller why exactly we think that a repository is not valid.

his should significantly improve our ability to diagnose why we think a specific repository is invalid and gives callers the ability to act accordingly. As an added benefit, the refactoring removes paths from error messages in favor of error metadata, which should help us to further deduplicate errors in Sentry.

Merge request reports