summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2019-03-13 12:10:33 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2019-03-13 12:10:33 +0000
commit7d053cfe10c7be4327b774c6552d21594dcdd2be (patch)
tree91dea26905d926caf363973114d7f79c31e33f6b
parentFix paranthesis indent (diff)
downloadsynapse-7d053cfe10c7be4327b774c6552d21594dcdd2be.tar.xz
Retry on 400:M_UNRECOGNIZED
-rw-r--r--synapse/http/matrixfederationclient.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py
index 7efa7b7572..fc8cf92067 100644
--- a/synapse/http/matrixfederationclient.py
+++ b/synapse/http/matrixfederationclient.py
@@ -474,8 +474,7 @@ class MatrixFederationHttpClient(object):
                  long_retries=False, timeout=None,
                  ignore_backoff=False,
                  backoff_on_404=False,
-                 try_trailing_slash_on_404=False,
-            ):
+                 try_trailing_slash_on_404=False):
         """ Sends the specifed json data using PUT
 
         Args:
@@ -662,14 +661,19 @@ class MatrixFederationHttpClient(object):
 
         response = yield self._send_request(**send_request_args)
 
+        body = yield _handle_json_response(
+            self.hs.get_reactor(), self.default_timeout, request, response,
+        )
+
         # If enabled, retry with a trailing slash if we received a 404
-        if try_trailing_slash_on_404 and response.code == 404:
+        # or if a 400 with "M_UNRECOGNIZED" which some endpoints return
+        if (try_trailing_slash_on_404 and
+           (response.code == 404
+            or (response.code == 400
+                and body.get("errcode") == "M_UNRECOGNIZED"))):
             args["path"] += "/"
             response = yield self._send_request(**send_request_args)
 
-        body = yield _handle_json_response(
-            self.hs.get_reactor(), self.default_timeout, request, response,
-        )
         defer.returnValue(body)
 
     @defer.inlineCallbacks