Compare commits

...

2 Commits

Author SHA1 Message Date
Erik Johnston
d2e0c0c927 Newsfile 2025-02-06 12:17:17 +00:00
Erik Johnston
af84f1d7aa Don't log exceptions for onbvious incorrect stream tokens
We log incorrect ones as we want to catch bugs where Synapse returns bad
tokens. However, sometimes clients just send tokens that are e.g. empty.
2025-02-06 12:15:56 +00:00
2 changed files with 7 additions and 0 deletions

1
changelog.d/18139.misc Normal file
View File

@@ -0,0 +1 @@
Do not log exceptions when clients provide empty `since` token to `/sync` API.

View File

@@ -664,6 +664,12 @@ class RoomStreamToken(AbstractMultiWriterStreamToken):
@classmethod
async def parse(cls, store: "PurgeEventsStore", string: str) -> "RoomStreamToken":
# Check it looks like a Synapse token first. We do this so that
# we don't log exceptions for obviously incorrect tokens.
if not string or string[0] not in ("s", "t", "m"):
logger.warning("Invalid token %r", string)
raise SynapseError(400, f"Invalid room stream token {string:!r}")
try:
if string[0] == "s":
return cls(topological=None, stream=int(string[1:]))