Skip to content

Resolve ""Merge failed: Something went wrong during merge: 9:not fast forward." when merged via API call"

What does this MR do and why?

When the API is used to merge the MR straight away, there may be a merge_error returned, which is swallowed and an error is added on the object itself. Even though the merge fails, we present it as if it passes.

We could get a merge error, and we handle it here: https://gitlab.com/gitlab-org/gitlab/-/blob/06083e36c740ae1184956e431ca681c638a2acb2/app/services/merge_requests/merge_service.rb#L42

Which means we only add it to the merge request: https://gitlab.com/gitlab-org/gitlab/-/blob/06083e36c740ae1184956e431ca681c638a2acb2/app/services/merge_requests/merge_service.rb#L146

When we present it: https://gitlab.com/gitlab-org/gitlab/-/blob/06083e36c740ae1184956e431ca681c638a2acb2/lib/api/merge_requests.rb#L484 it doens't look it the errors change the status code (which would be weird behaviour though.

We need to only unlock_mr if the mr is locked, otherwise an error will be put on the object for an invalid transition.

Related to #299188 (closed)

Edited by Marc Shaw

Merge request reports