Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: report SAML issue as fatal #1148

Merged
merged 2 commits into from
Jun 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be ordered?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SAML error also match 'The requested URL returned error, 403'. So first match first raise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that could have been great to have a bunch of unit test around these actually, so we're sure we don't break those.

[
(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