When submitting a Merge Request and Merge Method is set to Fast-forward merge, no error message is displayed when a pre-receive hook fails
Summary
When a project's Merge Method is set to "Fast-forward merge", no error message is displayed in the UI when a pre-receive hook fails. The "Merge" button will clock indefinitely until the user refreshes the page, at which point it will return to green.
Steps to reproduce
- Create a new project
- In Settings, set Merge Method to "Fast-forward merge"
- Make a change and create an MR
- In
/var/opt/gitlab/git-data/repositories/project_name.git
, create directorycustom_hooks
- Create a file titled
pre-receive
in the new directory - Enter the following code in the new file:
#!/usr/bin/env python3
import sys
print("pre-receive hook error message")
sys.exit(1)
- Submit the MR, no error is displayed
- If you change the Merge Method to "Merge commit" and try again the expected error message will be displayed
What is the current bug behavior?
The MR page will clock indefinitely after clicking "Merge".
What is the expected correct behavior?
The "Something went wrong during merge pre-receive hook" error message should be displayed. Note that gitlab-ce#48132, currently scheduled for 11.7, will change this generic error message to something more detailed.
Relevant logs and/or screenshots
When the pre-receive hook returns failure production.log
shows the merge are reverting to an "opened" status:
root/hook-test!6 - Merge process finished on JID with state opened
No errors indicating that the hook failed are logged.
For comparison, when this problem does not occur (i.e. fast-forward merge is NOT enabled) we expect to the following errors in production.log
:
MergeService ERROR: root/hook-test!6 - pre-receive hook error message<br>
MergeService ERROR: root/hook-test!6 - Something went wrong during merge pre-receive hook
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:env:info
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production
)
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...GitLab Shell version >= 8.3.3 ? ... OK (8.3.3) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 1/1 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
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: ... 1/1 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.4.4) Git version >= 2.9.5 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 1 Elasticsearch version 5.1 - 5.5? ... skipped (elasticsearch is disabled)
Checking GitLab ... Finished
/cc @jramsay @smcgivern