When there are unresolved discussions, the MR merge API provides an unhelpful error
When a project requires that all discussions are resolved for an MR to be merged, and you try to merge an MR in the API where there are unresolved discussions, you are presented with a simple "405 Method Not Allowed.". This can make it hard to figure out why a merge failed. The problem in the API code appears to be the following:
not_allowed! unless merge_request.mergeable_state?(skip_ci_check: merge_when_pipeline_succeeds)
This leads to the following code:
def mergeable_state?(skip_ci_check: false, skip_discussions_check: false)
return false unless open?
return false if work_in_progress?
return false if broken?
return false unless skip_ci_check || mergeable_ci_state?
return false unless skip_discussions_check || mergeable_discussions_state?
true
end
This leads to:
def mergeable_discussions_state?
return true unless project.only_allow_merge_if_all_discussions_are_resolved?
!discussions_to_be_resolved?
end
It would be nice if the error included a short message that describes why the merge failed.