Newlines in custom server hook error messages render improperly in merge UI

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Summary

Newlines in custom system hook error messages do not render correctly in the merge request UI on attempted merge.

Steps to reproduce

Create a new repository with an empty README.md. Create a new branch within that repository with some arbitrary content and submit a merge request.

Then create a custom hook within the given repository with a multiple messages, as follows:

#!/bin/sh

echo "GL-HOOK-ERR: User is ${GL_ID}"
echo "GL-HOOK-ERR: Do better."
exit 1

Finally attempt to merge that MR.

What is the current bug behavior?

Newlines are replaced and rendered as literal <br> but not rendered as html (so are displayed literally).

What is the expected correct behavior?

Messages should be displayed on separate lines, as appropriate.

Relevant logs and/or screenshots

The problem: ui-merge-pre-receive

How it should (and does display in the edit/commit UI): ui-edit-pre-receive

Possible fixes

Relevant bit of code, but not necessarily where to fix this:
https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/utils.rb#L94

Edited Dec 05, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading