summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2016-09-09 15:09:46 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2016-09-09 15:11:31 +0100
commit776594f99dc082a9a933ec6db6955b56ecd1363b (patch)
tree0b8ca3d2ab718419ad7dd50cc4878fbbc05a2e46 /synapse
parentReject malformed 3PE query metadata results earlier in AS API handling code (diff)
downloadsynapse-776594f99dc082a9a933ec6db6955b56ecd1363b.tar.xz
Log if rejecting 3PE query metadata result due to type check
Diffstat (limited to 'synapse')
-rw-r--r--synapse/appservice/api.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/synapse/appservice/api.py b/synapse/appservice/api.py
index afc64ed267..b0eb0c6d9d 100644
--- a/synapse/appservice/api.py
+++ b/synapse/appservice/api.py
@@ -32,6 +32,14 @@ HOUR_IN_MS = 60 * 60 * 1000
 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
@@ -164,10 +172,9 @@ class ApplicationServiceApi(SimpleHttpClient):
             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)