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

Commit

Permalink
Log if rejecting 3PE query metadata result due to type check
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul "LeoNerd" Evans committed Sep 9, 2016
1 parent ed44c47 commit 776594f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions synapse/appservice/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
APP_SERVICE_PREFIX = "/_matrix/app/unstable"


def _is_valid_3pe_metadata(info):
if "instances" not in info:
return False
if not isinstance(info["instances"], list):
return False
return True


def _is_valid_3pe_result(r, field):
if not isinstance(r, dict):
return False
Expand Down Expand Up @@ -164,10 +172,9 @@ def _get():
try:
info = yield self.get_json(uri, {})

# Ignore any result that doesn't contain an "instances" list
if "instances" not in info:
defer.returnValue(None)
if not isinstance(info["instances"], list):
if not _is_valid_3pe_metadata(info):
logger.warning("query_3pe_protocol to %s did not return a"
" valid result", uri)
defer.returnValue(None)

defer.returnValue(info)
Expand Down

0 comments on commit 776594f

Please sign in to comment.