Lesstep
GitLab · merge requests · auto-merge · Checked October 24, 2026

GitLab: why auto-merge was refused, merged at once, or canceled

Auto-merge asks GitLab to merge a merge request once its merge checks pass. Through the merge API it is auto_merge: true, from GitLab 17.11; before that it was merge_when_pipeline_succeeds: true, which 17.11 deprecated. Since GitLab 17.7 it waits for all the merge checks, not only the pipeline (GitLab's auto-merge docs). GitLab can still answer 405, merge it on the spot, or cancel it later. All of the following was checked on October 24, 2026 in GitLab's source (lib/api/merge_requests.rb, app/services/auto_merge/merge_when_checks_pass_service.rb, app/models/merge_request.rb) and its merge API docs.

The answers explained below, as GitLab sends them. The last two come from cancelling auto-merge on a merge request that is not set to it, with the newer and the older endpoint:

405 {"message":"405 Method Not Allowed"}
409 Can't cancel the automatic merge
201 {"message":"Can't cancel the automatic merge","status":"error","http_status":406}

What GitLab does with auto_merge

When auto-merge is set, the answer is 200 with "state":"opened" and "merge_when_pipeline_succeeds":true. On a project with merge trains, the request adds the merge request to the train instead, since GitLab 19.1.

To set auto-merge from the IDE: Merge Request (MR) Review Inbox for GitLab, a plugin for JetBrains IDEs, offers auto-merge in its Merge dialog while the pipeline runs, and sends both auto_merge and merge_when_pipeline_succeeds, so GitLab versions before and after 17.11 understand it.

The two 405s that surprise

When GitLab cancels auto-merge

From GitLab's docs, it cancels auto-merge when new commits are pushed to the source branch, so that they get a review. It also cancels it when commits are added to the target branch and the merge method is fast-forward or semi-linear without automatic rebase before merge. Keeping it set when that rebase is on came in GitLab 19.3, behind a feature flag that is off by default. The merge request's activity shows a note when GitLab cancels or aborts auto-merge. When it aborts, the note gives the reason: aborted the automatic merge because the source branch was updated. Learn more., aborted the automatic merge because the target branch was updated. (the fast-forward case above), aborted the automatic merge because the target branch was changed., aborted the automatic merge because the merge request was closed. or aborted the automatic merge because the target branch was merged in !123. when the target branch was itself merged with its source branch deleted. On a merge train the note begins removed this merge request from the merge train because instead (GitLab's refresh_service.rb, update_service.rb, close_service.rb and post_merge_service.rb).

When GitLab removes it from the merge train

On a merge train (GitLab Premium and Ultimate), the activity shows removed this merge request from the merge train because and the reason. Most reasons end with a Learn more link to GitLab's merge trains docs (GitLab's refresh_merge_request_service.rb). GitLab also gives the author, and the user who set it to merge, a to-do item Removed from Merge Train. When someone removes it by hand, the note is only removed this merge request from the merge train, with no reason (GitLab's merge_train_service.rb).

On the merge request page, while it waits, the widget shows This merge request is #2 of 3 in queue. or A new merge train has started and this merge request is first in the queue. If you have the page open when it leaves the train, GitLab shows This merge request was removed from the merge train. When the latest pipeline failed or was canceled, the merge button first opens Start merge train: The latest pipeline failed for this merge request. Do you still want to merge? Where the project does not enforce the merge train, the merge menu also has Merge immediately, which warns Merging immediately is not recommended because your changes won't be validated by the merge train, and any running merge train pipelines will be restarted. and asks Are you sure you want to merge immediately? When the project allows skipping the merge train, the menu has Merge now and restart train and Merge now and don't restart train instead (GitLab's merge_widget.vue and, in ee/, merge_train_position_indicator.vue and ready_to_merge.js). Each of the two opens a dialog with its own name as the title and the button. The restart one gives the warning above, and the other says Merging immediately is not recommended. The merged changes could cause pipeline failures on the target branch, and the changes will not be validated against the commits being added by the merge requests currently in the merge train. (merge_train_restart_train_confirmation_dialog.vue in ee/). The difference is on the server. Before the merge, Merge now and don't restart train records the merge request in the train's history, so when its commit lands on the target branch, GitLab knows it and leaves the running pipelines alone. A commit on the target branch that the train does not know makes GitLab mark the first merge request's pipeline as outdated, and the train starts again (in ee/, merge_service.rb, merge_trains/car.rb and check_status_service.rb).

Cancelling it

What to do

GitLab merge requests in IntelliJ IDEA

Merge Request (MR) Review Inbox for GitLab, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, shows a merge request's merge checks before you merge and merges the head commit you had on screen. While the pipeline runs, its Merge dialog offers auto-merge, and sends both auto_merge and merge_when_pipeline_succeeds, so GitLab versions before and after 17.11 understand it. When GitLab merges at once instead, it says the merge request was merged. From version 1.0.15, when GitLab refuses auto-merge (405), it says that auto-merge does not wait for a rebase the merge method needs, and to merge without auto-merge when the pipeline has already ended without succeeding; when GitLab answers but sets nothing, it says so. Before, it gave the message for an ordinary merge, which names a draft, threads, approvals and the pipeline, all of which auto-merge waits for. Reading is free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).

Get it on JetBrains Marketplace

GITLAB is a trademark of GitLab Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitLab Inc. or JetBrains.

More: GitLab merge refused (400, 401, 405, 409, 422) · GitLab rebase refused or failed (403, 409) · GitLab approval refused (401, 409) · GitLab "insufficient_scope" · GitLab 401 "invalid_token" · GitLab merge request list refused (400, 404) · GitLab merge request changes cut short ("1000+", too_large) · GitLab 429 "Retry later" (rate limits) · GitLab merge refused or failed over squashing · GitLab "compare_timeout": true (diff limits) · GitLab merge request plugins for IntelliJ IDEA, compared · 日本語