diff --git a/changelog.d/18139.misc b/changelog.d/18139.misc new file mode 100644 index 0000000000000000000000000000000000000000..f753033b8ec8b7dd7f9f23aad84955a9ac07747d --- /dev/null +++ b/changelog.d/18139.misc @@ -0,0 +1 @@ +Do not log at the exception-level when clients provide empty `since` token to `/sync` API. diff --git a/synapse/types/__init__.py b/synapse/types/__init__.py index 26783c56221c44af9494d7a8c46e4582c9880bc2..3d15c04faa57bd73e1828926266312e22964da7a 100644 --- a/synapse/types/__init__.py +++ b/synapse/types/__init__.py @@ -664,6 +664,11 @@ class RoomStreamToken(AbstractMultiWriterStreamToken): @classmethod async def parse(cls, store: "PurgeEventsStore", string: str) -> "RoomStreamToken": + # Check that it looks like a Synapse token first. We do this so that + # we don't log at the exception-level for obviously incorrect tokens. + if not string or string[0] not in ("s", "t", "m"): + raise SynapseError(400, f"Invalid room stream token {string:!r}") + try: if string[0] == "s": return cls(topological=None, stream=int(string[1:]))