Skip to content

Fix internal API errors not being passed back to UserMergeBranch

When a file is locked in GitLab (https://docs.gitlab.com/ee/user/project/file_lock.html) and a user attempts to merge a branch that contains this locked file, the /api/v4/internal/allowed endpoint will reject the push with an error such as:

GitLab: The path 'test' is locked by Administrator

In the Ruby implementation of UserMergeBranch, this error would have been passed up as a pre-receive error, and GitLab Rails will display any lines that are prefaced with GitLab:.

However, in the Go implementation, the error in the hooks are expected to be read from stdout and stderr of a forked process, but the API endpoint is run before this process is even run. Since stdout and stderr are blank, the pre-receive error message is returned as a blank message. As a result, Rails displays the wrong message, since it assumes the merge failed due to a conflict.

To fix this, we raise a NotAllowedError if the /internal/allowed endpoint fails and return that message.

Closes #3404 (closed)

Edited by Stan Hu

Merge request reports

Loading