Draft Merge Request automatically merged if a different MR with same commits is merged
Summary
If a draft merge request currently holds the same commits as another merge request, then completing the merge on one merge request will automatically merge the other MR despite being in "Draft" and on a separate source branch.
It appears someone else had this issue in the discussion here: https://forum.gitlab.com/t/potential-gitlab-bug-merging-a-mr-caused-a-second-but-inverse-mr-to-automatically-merge/71704
This old issue may be related, but insufficient detail is given on how to reproduce: #234819 (closed)
Steps to reproduce
Scenario: Two developers pick two separate issues and start two separate merge requests with two different source branches from the same commit on the main branch. Dev#1 implements a fix on MR!1, but has not merged it yet. Dev#2 has not started work, but decides to merge Dev#1's fix into their feature branch for MR!2 ahead of time. MR!2 is still in draft. Dev#1 completes review and merges in their changes, which closes their issue. Much to the shock of Dev#2, their draft MR!2 was also merged and also closes their issue automatically.
Exact steps to reproduce:
- Create two issues (#1 (closed) and #2 (closed))
- Create two draft MRs from the two issues, creating two branches from the same "main" commit
- Dev1: Push 1 or more commits to branch#1 (shows up in MR!1)
- Dev2: Checkout branch#2, merge in commits from branch#1, push to branch#2 (shows same commits in MR!2)
- Dev1: Set MR!1 as "Ready" and complete the merge
Example Project
I created a public sample project where I conducted this at: https://gitlab.com/sorenson.james.j/sandbox I reproduced this on 2024-04-09 on Gitlab.com v16.11. The problem originally occurred on our self-hosted "Ultimate" enterprise server at https://gitlab.us.lmco.com v16.5.8
What is the current bug behavior?
MR!2 will be automatically merged to main, despite still being in "Draft" status with a different source branch. Referenced issue #2 (closed) will also be closed as a result.
What is the expected correct behavior?
No actions on MR!2. It remains in open/draft status and issue #2 (closed) is still open.
Relevant logs and/or screenshots
The "before" status of the two merge requests:
The result of MR!2 after I merged MR!1:
Output of checks
This bug happens on GitLab.com v16.11
Results of GitLab environment info
N/A
Results of GitLab application Check
N/A
Possible fixes
N/A