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
setMergeErrormoves the widget into itsfailedToMergestate, and a refused rebase leaves the merge request open and mergeable. The banner also reads the persistedmerge_errorcolumn, 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 branchstill does not name the protected-branch rule that denied it, and changing those strings is a separate change.
References
Closes #623394
- Put
merge_erroron 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. |
![]() |
|
| 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
- In a project, protect the default branch and leave Allowed to force push cleared.
- Fork the project, then commit to that branch in the upstream project, so a merge request from the fork falls behind its target.
- Open a merge request from the fork's protected branch into the upstream project.
- As a user allowed to push to that branch, expand Merge details and select Rebase source branch.
- 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.
