Fix 500 when searching commit messages with non-ASCII terms
What does this MR do and why?
Searching commit messages on the new commit list with any non-ASCII term (Korean, Chinese, emoji, accented Latin) raised Encoding::UndefinedConversionError and returned a 500 (the frontend showed Unexpected token '<' ... is not valid JSON). In lib/gitlab/gitaly_client/commit_service.rb#list_commits, commit_message_patterns is a protobuf bytes field, but patterns were appended without encode_binary — unlike the adjacent author/path params.
This MR encodes each pattern as binary (one-line change) and adds a regression spec. encode_binary only relabels the encoding without changing bytes, so Gitaly still receives raw UTF-8 and matches correctly; ASCII behavior is unchanged.
Error details
Encoding::UndefinedConversionError
message : U+D5C8(허) from UTF-8 to ASCII-8BIT
lib/gitlab/gitaly_client/commit_service.rb:341:in `+'
lib/gitlab/gitaly_client/commit_service.rb:341:in `list_commits'
app/graphql/resolvers/repositories/commits_resolver.rb:45:in `resolve_with_lookahead'References
- Resolves #621385 (closed)
Screenshots or screen recordings
| Before | After |
|---|---|
![]() |
![]() |
How to set up and validate locally
-
Seed commits with non-ASCII messages in any local project:
git clone <your-gdk-project> && cd <project> git switch -c unicode-fun git commit --allow-empty -m "허용된 커밋만 커밋하세요" git commit --allow-empty -m "修复了一个不存在的bug" git commit --allow-empty -m "🔥🔥🔥 hotfix: everything is fine 🔥🔥🔥" git commit --allow-empty -m "Ĥéllö Wörld: ûnicode åll thé wáy" git push -u origin unicode-fun -
Visit the project's commit list at
/-/commits/unicode-fun. -
Filter by message with each term below. On
mastereach raised a 500; with this MR they return the seeded commit (or an empty state) without error.Test cases
Search term Covers Expected 허용Korean (customer repro) 1 result, no error 不存在Chinese 1 result, no error 🔥4-byte emoji 1 result, no error Wörldaccented Latin 1 result, no error Initial commitASCII regression check unchanged behavior zzzz없음zzzznon-ASCII with no matches empty state, no error -
Alternatively, from the rails console:
repo = Project.find_by_full_path('<group>/<project>').repository repo.list_commits(ref: 'unicode-fun', query: '허용').commits.map(&:message) # before: Encoding::UndefinedConversionError — after: ["허용된 커밋만 커밋하세요"]
The regression spec fails on the unfixed code with the exact production error and passes with the fix.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

