Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Improve error msg when key-fetch fails #5896

Merged
merged 1 commit into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog.d/5896.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve the logging when we have an error when fetching signing keys.
12 changes: 7 additions & 5 deletions synapse/crypto/keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from collections import defaultdict

import six
from six import raise_from
from six.moves import urllib

import attr
Expand Down Expand Up @@ -657,9 +656,10 @@ def get_server_verify_key_v2_indirect(self, keys_to_fetch, key_server):
},
)
except (NotRetryingDestination, RequestSendFailed) as e:
raise_from(KeyLookupError("Failed to connect to remote server"), e)
# these both have str() representations which we can't really improve upon
raise KeyLookupError(str(e))
except HttpResponseException as e:
raise_from(KeyLookupError("Remote server returned an error"), e)
Copy link
Member

@erikjohnston erikjohnston Aug 21, 2019

Choose a reason for hiding this comment

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

Its worth noting that in py3 adding an exception as context happens implicitly when raising from within an except block, aiui. (i.e. removing the raise_from here doesn't actually change anything)

Copy link
Member Author

Choose a reason for hiding this comment

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

oh rly?

raise KeyLookupError("Remote server returned an error: %s" % (e,))

keys = {}
added_keys = []
Expand Down Expand Up @@ -821,9 +821,11 @@ def get_server_verify_key_v2_direct(self, server_name, key_ids):
timeout=10000,
)
except (NotRetryingDestination, RequestSendFailed) as e:
raise_from(KeyLookupError("Failed to connect to remote server"), e)
# these both have str() representations which we can't really improve
# upon
raise KeyLookupError(str(e))
except HttpResponseException as e:
raise_from(KeyLookupError("Remote server returned an error"), e)
raise KeyLookupError("Remote server returned an error: %s" % (e,))

if response["server_name"] != server_name:
raise KeyLookupError(
Expand Down