Skip to content

Allow custom hooks errors to appear in GitLab UI

What does this MR do?

This is re-enabling a feature that had been disabled in merge request https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18646

PreReceiveErrors (errors from pre-receive, post-receive and update custom hooks) had been disabled due to security concerns that information which was not intended to be public (like stack traces) would leak into public view.

In this MR, PreReceiveErrors are now filtered for messages that have been prefixed in a particular way that marks them as safe for public display in the UI.

There are two prefixes that will allow the message to be filtered: GitLab: and GL-HOOK-ERR:. GitLab: is already used for prefixing error messages in gitlab-shell that are output as PreReceiveErrors in gitaly (here and here), and we want to allow users to see these messages. GL-HOOK-ERR: is what we want users to add to their custom hook scripts in order for the output to be seen in the UI if the script errors. This is described in this MR's documentation changes.

I've updated all specs that tested PreReceiveError messages to use the prefix GitLab: rather than GL-HOOK-ERR:, i.e., for the tests to be consistent and preferring an error message as it would come from gitlab-shell.

What are the relevant issue numbers?

https://gitlab.com/gitlab-org/gitlab-ce/issues/48132

Does this MR meet the acceptance criteria?

Closes #48132 (closed)

Edited by Luke Duncalfe

Merge request reports