smarkets / marge-bot

A merge-bot for GitLab
BSD 3-Clause "New" or "Revised" License
693 stars 136 forks source link

Hard-to-interpret messages when discussions are unresolved #363

Open perlun opened 1 year ago

perlun commented 1 year ago

I currently got this in an MR:

I couldn't merge this branch: had some issue with GitLab, check my logs...

Here's what it logged:

2022-12-07 13:19:09,142 INFO Ensuring MR !8929 is mergeable
2022-12-07 13:19:09,782 ERROR Unanticipated ApiError from GitLab on merge attempt
Traceback (most recent call last):
  File "/nix/store/0ljil4j1g16cr8i3f2viha9rdjhcvyb7-python3.6-marge-0.10.0/lib/python3.6/site-packages/marge/single_merge_job.py", line 88, in upda
te_merge_request_and_accept
    merge_when_pipeline_succeeds=bool(target_project.only_allow_merge_if_pipeline_succeeds),
  File "/nix/store/0ljil4j1g16cr8i3f2viha9rdjhcvyb7-python3.6-marge-0.10.0/lib/python3.6/site-packages/marge/merge_request.py", line 205, in accept
    sha=sha or self.sha,  # if provided, ensures what is merged is what we want (or fails)
  File "/nix/store/0ljil4j1g16cr8i3f2viha9rdjhcvyb7-python3.6-marge-0.10.0/lib/python3.6/site-packages/marge/gitlab.py", line 65, in call
    raise error(response.status_code, err_message)
marge.gitlab.Unprocessable: (422, {'message': 'Branch cannot be merged'})
2022-12-07 13:19:09,789 WARNING I couldn't merge this branch: had some issue with GitLab, check my logs...
2022-12-07 13:19:09,790 INFO Unassigning from MR !8929

The root cause

The root cause in this case was that I had an unresolved discussion in the MR, and we have our GitLab configured to require discussions to be resolved before merging. It's a silly mistake but it actually took me some time to figure this out this time... Perhaps we could make Marge-bot smarter by checking if all discussions are resolved before it attempts to merge. :thinking: