Better error message on [Unprocessable] errors from GitLab API
Related: #2
If a user assigns an MR to marge-bot that has unmerged MR dependencies, then GitLab's merge API endpoint throws an 422 Unprocessable
error with the message Branch cannot be merged
.
The message that marge leaves on the MR in this case is
I couldn't merge this branch: had some issue with GitLab, check my logs...
which is not very helpful.
In this MR, we catch the unprocessable errors, and we post an error message to the MR in question.
Note that the GitLab API does not expose any endpoint allowing us to check whether there are unmet MR dependencies: gitlab-org&8173
With this MR, we get the following log messages:
2023-11-15 14:36:26,679 INFO Ensuring MR !8 is mergeable
2023-11-15 14:36:27,767 WARNING Unanticipated Unprocessable error from GitLab on merge attempt
2023-11-15 14:36:27,768 WARNING I couldn't merge this branch: GitLab could not merge this branch (message: 'Branch cannot be merged'). This can happen if the MR has unmerged dependencies.
2023-11-15 14:36:27,768 INFO Unassigning from MR !8
Edited by Arvid Jakobsson