From 1d208fa17ec723e1ab324ac1d5cffaf69cae73ef Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Fri, 29 Jul 2022 00:16:59 -0500 Subject: [PATCH] Fix invalid attribute type ``` Invalid type StreamToken for attribute value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those types ``` Had to add a few more logs to find this instance since the warning doens't give much info where I am setting this invalid attribute. This was good enough to find it in the code. ``` BoundedAttributes __setitem__ key=since_token value=StreamToken(room_key=RoomStreamToken(topological=None, stream=1787, instance_map=frozendict.frozendict({})), presence_key=481272, typing_key=0, receipt_key=340, account_data_key=1233, push_rules_key=8, to_device_key=57, device_list_key=199, groups_key=0) BoundedAttributes __setitem__ key=now_token value=StreamToken(room_key=RoomStreamToken(topological=None, stream=1787, instance_map=frozendict.frozendict({})), presence_key=481287, typing_key=0, receipt_key=340, account_data_key=1233, push_rules_key=8, to_device_key=57, device_list_key=199, groups_key=0) BoundedAttributes __setitem__ key=token value=StreamToken(room_key=RoomStreamToken(topological=None, stream=1787, instance_map=frozendict.frozendict({})), presence_key=481291, typing_key=0, receipt_key=340, account_data_key=1237, push_rules_key=8, to_device_key=57, device_list_key=199, groups_key=0) ``` --- synapse/handlers/sync.py | 10 +++++----- synapse/notifier.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index ad71feb774..8dc05d648d 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -396,7 +396,7 @@ class SyncHandler: indoctrination. """ with start_active_span("sync.current_sync_for_user"): - log_kv({"since_token": since_token}) + log_kv({"since_token": str(since_token)}) sync_result = await self.generate_sync_result( sync_config, since_token, full_state ) @@ -1089,7 +1089,7 @@ class SyncHandler: # to query up to a given point. # Always use the `now_token` in `SyncResultBuilder` now_token = self.event_sources.get_current_token() - log_kv({"now_token": now_token}) + log_kv({"now_token": str(now_token)}) logger.debug( "Calculating sync response for %r between %s and %s", @@ -2007,8 +2007,8 @@ class SyncHandler: log_kv( { - "since_token": since_token, - "upto_token": upto_token, + "since_token": str(since_token), + "upto_token": str(upto_token), } ) @@ -2023,7 +2023,7 @@ class SyncHandler: log_kv( { "batch_events": len(batch.events), - "prev_batch": batch.prev_batch, + "prev_batch": str(batch.prev_batch), "batch_limited": batch.limited, } ) diff --git a/synapse/notifier.py b/synapse/notifier.py index 889ea22379..8fd8cb8100 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -536,7 +536,7 @@ class Notifier: log_kv( { "wait_for_events": "sleep", - "token": prev_token, + "token": str(prev_token), } ) @@ -546,7 +546,7 @@ class Notifier: log_kv( { "wait_for_events": "woken", - "token": user_stream.current_token, + "token": str(user_stream.current_token), } )