Skip to content

Changelog API raises Exception on Non-Ascii content in commit trailers

Summary

When I use a git commit trailer with a non-Ascii character (e.g. a german umlaut like ä), the changelog API returns a 500: Internal server error. On further investigation, this is due to a Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8 exception.

Steps to reproduce

  1. Create an empty gitlab project
  2. Create a few commits with trailers to have the working changelog
  3. Create a commit with a trailer that contains/is for example Äpfel
  4. See the changelog API return a 500 error, see the exception in the logfile.

It does not matter if there is a changelog_config.yml or not.

Relevant logs and/or screenshots

[...]
"route": "/api/:version/projects/:id/repository/changelog",
    "user_id": 25,
    "username": "project_1_bot_2ec0e4994c0ab48401127602e2878db0",
    "token_type": "PersonalAccessToken",
    "token_id": 7,
    "exception.class": "Encoding::CompatibilityError",
    "exception.message": "incompatible character encodings: ASCII-8BIT and UTF-8",
    "exception.backtrace": [
        "lib/gitlab/template_parser/ast.rb:79:in `join'",
        "lib/gitlab/template_parser/ast.rb:79:in `evaluate'",
        "lib/gitlab/template_parser/ast.rb:122:in `block (2 levels) in evaluate'",
        "lib/gitlab/template_parser/ast.rb:122:in `map'",
        "lib/gitlab/template_parser/ast.rb:122:in `block in evaluate'",
        "lib/gitlab/template_parser/eval_state.rb:19:in `enter_loop'",
        "lib/gitlab/template_parser/ast.rb:121:in `evaluate'",
        "lib/gitlab/template_parser/ast.rb:79:in `block in evaluate'",
        "lib/gitlab/template_parser/ast.rb:79:in `map'",
        "lib/gitlab/template_parser/ast.rb:79:in `evaluate'",
        "lib/gitlab/template_parser/ast.rb:95:in `evaluate'",
        "lib/gitlab/template_parser/ast.rb:79:in `block in evaluate'",
        "lib/gitlab/template_parser/ast.rb:79:in `map'",
        "lib/gitlab/template_parser/ast.rb:79:in `evaluate'",
        "lib/gitlab/changelog/release.rb:69:in `to_markdown'",
        "lib/gitlab/changelog/generator.rb:39:in `add'",
        "app/services/repositories/changelog_service.rb:124:in `execute'",
        "lib/api/repositories.rb:296:in `block (2 levels) in <class:Repositories>'",
[...]

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:
Current User:   git
Using RVM:      no
Ruby Version:   3.1.5p253
Gem Version:    3.5.9
Bundler Version:2.5.9
Rake Version:   13.0.6
Redis Version:  7.0.15
Sidekiq Version:7.1.6
Go Version:     unknown

GitLab information
Version:        17.0.2
Revision:       5dd286b6ff3
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     14.11
URL:            
HTTP Clone URL: 
SSH Clone URL:  git@
Using LDAP:     yes
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        14.35.0
Repository storages:
- default:      unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell

Gitaly
- default Address:      unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version:      17.0.2
- default Git Version:  2.44.2.gl1

Results of GitLab application Check

Expand for output related to the GitLab application check
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 14.35.0 ? ... OK (14.35.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 28 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Database config exists? ... yes Tables are truncated? ... skipped All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 41/1 ... yes 4/3 ... yes 36/4 ... yes 4/5 ... yes 4/6 ... yes 4/7 ... yes 35/8 ... yes 36/9 ... yes 36/10 ... yes 36/11 ... yes 3/12 ... yes 37/13 ... yes 36/14 ... yes 36/15 ... yes 36/16 ... yes 27/17 ... yes 4/18 ... yes 41/20 ... yes 36/21 ... yes 41/22 ... yes 41/23 ... yes 4/24 ... yes 41/25 ... yes 41/26 ... yes 36/27 ... yes 41/28 ... yes 4/29 ... yes 4/30 ... yes 41/31 ... yes 37/32 ... yes 37/33 ... yes 4/34 ... yes 4/35 ... yes 41/36 ... yes 36/37 ... yes 37/38 ... yes 41/39 ... yes Redis version >= 6.2.14? ... yes Ruby version >= 3.0.6 ? ... yes (3.1.5) Git user has default SSH configuration? ... yes Active users: ... 23 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes