Validate branches Cannot Create: This merge request already exists
Summary
Lost new merge request details because there was an error when creating the merge request. There was already another open merge request involving the same branches, but no warning that this would cause an error.
Original bug report
Steps to reproduce
- Create a new merge request from branch A into branch B. Save the merge request.
- Open another new merge request from branch A into branch B, and click the "Submit merge request" button to save.
- You are taken to the first New Merge Request page with an error message.
The error says:
The form contains the following error:
* Validate branches Cannot Create: This merge request already exists: ["WIP: Workflow"]
Example Project
What is the current bug behavior?
The merge request isn't created, and there is no way to retrieve the details entered for it.
What is the expected correct behavior?
You shouldn't be able to create a duplicate MR. But if you do and you get the error, you should be able to view the details of the merge request.
Relevant logs and/or screenshots
(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
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
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:check SANITIZE=true`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`) (we will only investigate if the tests are passing)
Workaround
Hit back button in browser to get MR information.
Possible fixes
Check errors before navigating away from page
If I start from Create merge request
and am presented with the branch options, I'm still able to go through that screen, fill out the New MR form
, and only then do I get the error that the MR already exists:
click Create merge request from MR list page, select branches |
fill out MR form | end up back at branch selection with error |
---|---|---|
![]() |
![]() |
![]() |
Proposal
Validate the branches before you actually get to the MR form. If there is already an open MR, show an alert (danger variant) at the top of the page with the following text:
These branches already have an open merge request: <linked MR reference, e.g. !aaa>. Select a different source or target branch.