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

Screenshots or screen recordings

Before After
CleanShot 2026-08-24 at 13.45.49.png CleanShot 2026-08-24 at 13.42.51.png

How to set up and validate locally

  1. 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
  2. Visit the project's commit list at /-/commits/unicode-fun.

  3. Filter by message with each term below. On master each 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örld accented Latin 1 result, no error
    Initial commit ASCII regression check unchanged behavior
    zzzz없음zzzz non-ASCII with no matches empty state, no error
  4. 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.

Edited by Chaoyue Zhao

Merge request reports

Loading
Loading