From a063525ed71281770106c147c1c8176e19e963d5 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 20 Jan 2022 16:24:15 +0000 Subject: Add debug logging for #11772 --- synapse/util/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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) ) -- cgit 1.4.1