Skip to content

Commit

Permalink
fix: report SAML issue as fatal
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sileht authored and mergify[bot] committed Jun 3, 2020
1 parent ea26eaa commit 6238665
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions mergify_engine/branch_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# under the License.


import collections
import subprocess
import uuid

Expand Down Expand Up @@ -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"])

Expand Down

0 comments on commit 6238665

Please sign in to comment.