/-/commits returns 500 Encoding Error
Summary
Accessing a project's /-/commits endpoint returns a 500 Encoding Error from certain commits on. Accessing /-/commits/$SHA works fine from the project's start up to some commit and starts returning the error for all commits after that. Accessing /-/commit/$SHA does not cause the error, only /-/commits/$SHA does (from some point on).
The behaviour can be present in multiple branches. As soon as an affected branch is merged, the target branch becomes affected as well.
Similar buggy behaviour has been reported in the distant past, see this issue.
Steps to reproduce
Open /-/commits for an affected project in the browser.
Example Project
Sorry, the issue is data-dependent and I cannot disclose the project I'm seeing this in
What is the current bug behavior?
Browser shows a 500 Encoding Error page.
What is the expected correct behavior?
Browser displays a list of commits.
Relevant logs and/or screenshots
The following appears in gitlab-rails/production.log when the issue occurs.
Encoding::CompatibilityError (incompatible character encodings: UTF-8 and ASCII-8BIT):
app/views/projects/commits/_commit.html.haml:65
app/views/projects/commits/_commits.html.haml:20
app/views/projects/commits/_commits.html.haml:10:in `<<'
app/views/projects/commits/_commits.html.haml:10:in `each'
app/views/projects/commits/_commits.html.haml:10:in `each'
app/views/projects/commits/_commits.html.haml:10:in `each'
app/views/projects/commits/_commits.html.haml:10
app/views/projects/commits/show.html.haml:38
Output of checks
Results of GitLab environment info
Running in a Docker Compose setup with gitlab/gitlab-ce:15.10.0-ce.0.
Possible fixes
For all I can see in my afflicted project, the issue is triggered by the diff, which is a mix of text and binary changes. The encoding for the commit messages gives "" for all messages (git log --pretty='format: "%e"'). None of the commit messages trips up iconv -f utf-8.
If mixed encodings in the diff is indeed the cause, I find it odd that it is even looked at. There doesn't seem to be anything in the /-/commits that needs info beyond what the commit message can provide.
Sentry error
https://new-sentry.gitlab.net/organizations/gitlab/issues/62373