From 0c13b6e8492a9aa501bf55eef09f07db7b605add Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Tue, 2 Jun 2020 09:28:10 +0200 Subject: [PATCH] fix: report SAML issue as fatal Currently this is catched as AuthentificationFailure making Mergify retrying for ever. This change mark the SAML message as fatal. So the error message coming from Github is reported on the PullRequest. Related #1145 Fixes MERGIFY-ENGINE-1MG --- mergify_engine/branch_updater.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/mergify_engine/branch_updater.py b/mergify_engine/branch_updater.py index 6554d5a77a..4e7b35f379 100644 --- a/mergify_engine/branch_updater.py +++ b/mergify_engine/branch_updater.py @@ -15,6 +15,7 @@ # under the License. +import collections import subprocess import uuid @@ -44,20 +45,23 @@ class AuthentificationFailure(Exception): pass -GIT_MESSAGE_TO_EXCEPTION = { - b"Invalid username or password": AuthentificationFailure, - b"Repository not found": AuthentificationFailure, - b"The requested URL returned error: 403": AuthentificationFailure, - b"Patch failed at": BranchUpdateFailure, - b"remote contains work that you do": BranchUpdateNeedRetry, - b"remote end hung up unexpectedly": BranchUpdateNeedRetry, - b"cannot lock ref 'refs/heads/": BranchUpdateNeedRetry, - b"Could not resolve host": BranchUpdateNeedRetry, - b"Operation timed out": BranchUpdateNeedRetry, - b"No such device or address": BranchUpdateNeedRetry, - b"Protected branch update failed": BranchUpdateFailure, - b"Couldn't find remote ref": BranchUpdateFailure, -} +GIT_MESSAGE_TO_EXCEPTION = collections.OrderedDict( + [ + (b"organization has enabled or enforced SAML SSO.", BranchUpdateFailure), + (b"Invalid username or password", AuthentificationFailure), + (b"Repository not found", AuthentificationFailure), + (b"The requested URL returned error, 403", AuthentificationFailure), + (b"Patch failed at", BranchUpdateFailure), + (b"remote contains work that you do", BranchUpdateNeedRetry), + (b"remote end hung up unexpectedly", BranchUpdateNeedRetry), + (b"cannot lock ref 'refs/heads/", BranchUpdateNeedRetry), + (b"Could not resolve host", BranchUpdateNeedRetry), + (b"Operation timed out", BranchUpdateNeedRetry), + (b"No such device or address", BranchUpdateNeedRetry), + (b"Protected branch update failed", BranchUpdateFailure), + (b"Couldn't find remote ref", BranchUpdateFailure), + ] +) GIT_MESSAGE_TO_UNSHALLOW = set([b"shallow update not allowed", b"unrelated histories"])