summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-02-28 14:10:36 +0000
committerGitHub <noreply@github.com>2022-02-28 14:10:36 +0000
commit5565f454e1b323b637dd418549f70fadac0f44b4 (patch)
tree698b789e7fdc6abe3ff05ba1fd44ffae9179148a
parentProperly failover for unknown endpoints from Conduit/Dendrite. (#12077) (diff)
downloadsynapse-5565f454e1b323b637dd418549f70fadac0f44b4.tar.xz
Actually fix bad debug logging rejecting device list & signing key transactions (#12098)
-rw-r--r--changelog.d/12098.bugfix1
-rw-r--r--synapse/federation/transport/server/federation.py2
-rw-r--r--tests/federation/transport/test_server.py20
3 files changed, 21 insertions, 2 deletions
diff --git a/changelog.d/12098.bugfix b/changelog.d/12098.bugfix
new file mode 100644
index 0000000000..6b696692e3
--- /dev/null
+++ b/changelog.d/12098.bugfix
@@ -0,0 +1 @@
+Fix a bug introduced in Synapse 1.51.0rc1 where incoming federation transactions containing at least one EDU would be dropped if debug logging was enabled for `synapse.8631_debug`.
\ No newline at end of file
diff --git a/synapse/federation/transport/server/federation.py b/synapse/federation/transport/server/federation.py
index 9cc9a7339d..23ce343057 100644
--- a/synapse/federation/transport/server/federation.py
+++ b/synapse/federation/transport/server/federation.py
@@ -110,7 +110,7 @@ class FederationSendServlet(BaseFederationServerServlet):
             if issue_8631_logger.isEnabledFor(logging.DEBUG):
                 DEVICE_UPDATE_EDUS = ["m.device_list_update", "m.signing_key_update"]
                 device_list_updates = [
-                    edu.content
+                    edu.get("content", {})
                     for edu in transaction_data.get("edus", [])
                     if edu.get("edu_type") in DEVICE_UPDATE_EDUS
                 ]
diff --git a/tests/federation/transport/test_server.py b/tests/federation/transport/test_server.py
index ce49d094d7..5f001c33b0 100644
--- a/tests/federation/transport/test_server.py
+++ b/tests/federation/transport/test_server.py
@@ -13,7 +13,7 @@
 # limitations under the License.
 
 from tests import unittest
-from tests.unittest import override_config
+from tests.unittest import DEBUG, override_config
 
 
 class RoomDirectoryFederationTests(unittest.FederatingHomeserverTestCase):
@@ -38,3 +38,21 @@ class RoomDirectoryFederationTests(unittest.FederatingHomeserverTestCase):
             "/_matrix/federation/v1/publicRooms",
         )
         self.assertEqual(200, channel.code)
+
+    @DEBUG
+    def test_edu_debugging_doesnt_explode(self):
+        """Sanity check incoming federation succeeds with `synapse.debug_8631` enabled.
+
+        Remove this when we strip out issue_8631_logger.
+        """
+        channel = self.make_signed_federation_request(
+            "PUT",
+            "/_matrix/federation/v1/send/txn_id_1234/",
+            content={
+                "edus": [
+                    {"edu_type": "m.device_list_update", "content": {"foo": "bar"}}
+                ],
+                "pdus": [],
+            },
+        )
+        self.assertEqual(200, channel.code)