Fix error 500 loading branch with UTF-8 characters with performance bar
What does this MR do and why?
When we added caching for protected branch names in !64738 (merged), we did not account for UTF-8 characters being used in the branch name.
The cache key would be encoded in ASCII-8BIT due to the branch name
coming from Gitaly, but when the performance bar were enabled the Redis
activity would be dumped to JSON. Since this string wasn't UTF-8, Ruby
would throw up a Encoding::UndefinedConversionError
.
This commit fixes the problem by hashing the ref name with SHA-1 to avoid needing to deal with any encoding issues.
Relates to https://gitlab.com/gitlab-org/gitlab/-/issues/343698
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Enable the performance bar.
- Create a branch
“jmd-add-tests-branch-vs-tags-issues”
. - With previous code, you would see a 500 error.
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.