Server hook custom error messages not displayed when merge fails
Summary
Merge requests that fail to merge due to a server hook rejecting the change do not display the custom error message in the UI.
Steps to reproduce
- Create a repository with a single file such as
README.md. - Clone the repository.
- Edit the file and push the change to a new branch.
- Create a server hook on the filesystem using the listed example hook:
#!/bin/sh
echo "GL-HOOK-ERR: My custom error message.";
exit 1
- Ensure the file is owned by the
gituser and has execute permissions. - Create a merge request for the branch.
- Attempt to merge the branch.
- The merge request fails to merge.
As a follow-up, change the hook to exit 0 and verify the merge can succeed which indicates the hook is being executed.
Example Project
This is reproduced by an empty repository with only a single file required to produce a non-empty merge request.
What is the current bug behavior?
The merge box says "Something went wrong during merge pre-receive hook..." but does not contain the custom error message. See screenshot.
What is the expected correct behavior?
The merge box should include the custom error message which provides necessary details to the user.
Relevant logs and/or screenshots
2021-11-19T16:07:06.246Z: root/test!2 - Git merge started on JID b04e14b7949db710c5c1340c
2021-11-19T16:07:06.562Z: MergeService ERROR: root/test!2 - Something went wrong during merge pre-receive hook.
2021-11-19T16:08:37.651Z: root/test!2 - Git merge started on JID 51be18dd9b46db21fdea536b
2021-11-19T16:08:37.961Z: MergeService ERROR: root/test!2 - Something went wrong during merge pre-receive hook.
2021-11-19T16:08:53.837Z: root/test!2 - Git merge started on JID c912066f1bf7dea1ab1778a2
2021-11-19T16:08:54.185Z: root/test!2 - Git merge finished on JID c912066f1bf7dea1ab1778a2 commit c6b559e3a2fb25f85cd49c882ef2ce2a3174a302
2021-11-19T16:08:54.227Z: Updating statistics for project 2
2021-11-19T16:08:54.604Z: root/test!2 - Post merge started on JID c912066f1bf7dea1ab1778a2 with state locked
2021-11-19T16:08:55.448Z: root/test!2 - Post merge finished on JID c912066f1bf7dea1ab1778a2 with state merged
2021-11-19T16:08:55.456Z: root/test!2 - Merge process finished on JID with state merged
2021-11-19T16:21:56.217Z: ActiveRecord connection established
Output of checks
Results of GitLab environment info
This was reproduced using the GitLab docker images 14.3.3-ee.0 and persisted after upgrading to latest which at time of writing is 14.4.2-ee. I was logged in as the root user.
Expand for output related to GitLab environment info
root@gitlab:/var/log/gitlab# gitlab-rake gitlab:env:info System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.4p191 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.6 Redis Version: 6.0.16 Git Version: 2.33.0. Sidekiq Version:6.2.2 Go Version: unknown GitLab information Version: 14.4.2-ee Revision: 84aa6daaffd Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.7 URL: http://gitlab.example.com:8929 HTTP Clone URL: http://gitlab.example.com:8929/some-group/some-project.git SSH Clone URL: ssh://git@gitlab.example.com:2224/some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.21.1 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git root@gitlab:/var/log/gitlab#
Results of GitLab application Check
Expand for output related to the GitLab application check
root@gitlab:/var/log/gitlab# gitlab-rake gitlab:check SANITIZE=true Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.21.1 ? ... OK (13.21.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successfulChecking 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: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... 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? ... skipped (no tmp uploads folder yet) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/1 ... yes 1/2 ... yes Redis version >= 5.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.4) Git version >= 2.33.0 ? ... yes (2.33.0) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
root@gitlab:/var/log/gitlab#
