Show why a rebase was rejected in the merge request widget

What does this MR do and why?

A rebase that GitLab refuses now tells the user why, in the merge widget and in the merge checks list.

Problem

Currently on master, someone who cannot rebase a merge request is told to try again, and trying again cannot work. The endpoint already answers with the reason, for example Source branch is protected from force push, but the merge widget reads a key the response does not carry and the merge checks list raises its alert only when no reason arrived. A protected source branch is the common case, and the message never says so. There is no feature flag: the widget has behaved this way since 17.9, the merge checks list since it was written in October 2023.

Review notes

  • Why not show the reason in the widget's merge-error banner? Because setMergeError moves the widget into its failedToMerge state, and a refused rebase leaves the merge request open and mergeable. The banner also reads the persisted merge_error column, which a rebase refused before it is queued never writes.
  • Why does the merge checks list now fall back to a different sentence? It changes from "Something went wrong. Please try again." to "Failed to rebase. Please try again.", so both buttons say the same thing when the backend sends no reason.
  • What is out of scope? The wording of the reasons. Cannot push to source branch still does not name the protected-branch rule that denied it, and changing those strings is a separate change.

🛠️ with ❤️ at Siemens

References

Closes #623394

  • Put merge_error on the wire in 14.6: !75496 (merged)
  • Made the UI and the API agree in 15.8 that a refused force push answers 403 with the reason: #386537 (closed)
  • Added the Rebase button to the widget in 17.9: !179906 (merged)
  • The same problem in the automatic rebase before a merge, related and not a duplicate: #616915 (closed)

Screenshots or screen recordings

Before After
Failed to rebase. Please try again. Failed to rebase: Source branch is protected from force push.
Screenshot_2026-08-26_at_16.04.57
No message Failed to rebase: Source branch is protected from force push.

Row one is the merge widget, row two the merge checks list.

How to set up and validate locally

  1. In a project, protect the default branch and leave Allowed to force push cleared.
  2. Fork the project, then commit to that branch in the upstream project, so a merge request from the fork falls behind its target.
  3. Open a merge request from the fork's protected branch into the upstream project.
  4. As a user allowed to push to that branch, expand Merge details and select Rebase source branch.
  5. For the merge checks list, set the upstream project's merge method to Fast-forward merge and use the Rebase button it offers.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Gerardo Navarro

Merge request reports

Loading
Loading