-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't log exceptions for obviously incorrect stream tokens #18139
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified "at the exception-level" because this change is a bit confusing otherwise (we still log and raise and exception, just not at the exception-level for obviously wrong tokens).
synapse/types/__init__.py
Outdated
# 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}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should think about just ignoring these obviously wrong tokens altogether or log at a much lower level.
# 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}") | |
# 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.debug("Invalid token %r", string) | |
raise SynapseError(400, f"Invalid room stream token {string:!r}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was going to suggest at least only logging the empty string case as debug
. It's plausible that a non-empty token is from a future synapse (after upgrade/downgrade) or something. However, I realised we'll log these tokens anyway when we return the 400 (as we log the error string), so actually adding an extra log line here is pointless, so I've removed it entirely.
Co-authored-by: Eric Eastwood <[email protected]>
Co-authored-by: Eric Eastwood <[email protected]>
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.