summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2022-01-20 16:24:15 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2022-01-20 16:39:56 +0000
commita063525ed71281770106c147c1c8176e19e963d5 (patch)
tree018c8eb78f6a44f654f6ad64642955f81e74f8e1
parentMerge branch 'release-v1.50' into matrix-org-hotfixes (diff)
downloadsynapse-github/anoa/log_11772.tar.xz
Add debug logging for #11772 github/anoa/log_11772 anoa/log_11772
-rw-r--r--synapse/util/__init__.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/synapse/util/__init__.py b/synapse/util/__init__.py
index 511f52534b..8dca85e27d 100644
--- a/synapse/util/__init__.py
+++ b/synapse/util/__init__.py
@@ -63,8 +63,18 @@ def _handle_frozendict(obj: Any) -> Dict[Any, Any]:
             # there isn't a `_dict` attribute with a dict
             # so we resort to making a copy of the frozendict
             return dict(obj)
+
+    elif hasattr(obj, "get_dict"):
+        copied_dict = obj.get_dict()
+
+        # Warn that a FrozenEvent was passed
+        logger.warning("Attempted to JSON serialise a %s: %s", type(obj), copied_dict)
+
+        # Return the non-frozen dict
+        return copied_dict
+
     raise TypeError(
-        "Object of type %s is not JSON serializable" % obj.__class__.__name__
+        "Object of type %s is not JSON serializable: %s" % (obj.__class__.__name__, obj)
     )