This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Do not try to store invalid data in the stats table #8226
Do not try to store invalid data in the stats table #8226
Changes from 3 commits
3329c8f
e1cbf94
228b715
8005dbb
a592557
a2ab4c7
94e8a18
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I'm not sure if it matters, but this changes the behaviour of fields that do not exist or are NULL.
Before, they would not be part of an upsert — now they will be upserted to
NULL
.Is this fine? I get a funny feeling it may not be.
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.
Yes, I think this would violate the assumption that seems to be part of
synapse/synapse/handlers/stats.py
Line 297 in b5133dd
I must apologise for the lack of docstring which makes it clear, though it also looks like I inherited this function..?
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.
Ah, I was assuming that the dictionary would include strings or None for all fields, but you're 100% correct that this does slightly change the behavior!
In the case of invalid data, does upserting with
None
make sense?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.
The code as-is will never "clear" a value (e.g. if topic goes from "foo" -> None it will be stale and stay at "foo" forever). I'm unsure if this is correct behavior.
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.
I guess I didn't think too hard about unsetting topics; can you do that, or would it be empty string? (not that empty string was properly handled to begin with, by the looks)...
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.
I think upserting with None when you get invalid data is fine, if that corresponds with the interpretation that clients, etc are meant to have.
If you get a history_visibility entry with an invalid value, what happens? Stays the same, or resets to some 'default' value? I suppose that is ultimately what might guide us here.
(Though this isn't used for any important information other than the room directory really, so as long as it always leads to a 'safer' outcome I suppose it's fine; e.g. not revealing private rooms in the public room list even if they have sent nonsense visibility and join rule state events)...
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.
I pushed some changes which should stop overriding data that wasn't submitted. I also fixed the issue of being unable to submit
None
values into the method. I'm not 100% sure that's correct or not though.