fix(MSC3911): Use different state retrieval function for graceful handling of missing state #126
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.
Using the
StorageController.state.get_state_for_events()function has a limitation, in that outlier events or filtered events will raise aRuntimeError. This appears to have been intended behavior, as other places this is called filter out events like outliers ahead of time which is the error's normal trigger.In our case, we are filtering for an extremely narrow set of two types of events, history visibility and a membership event of a user. This can sometimes lead to a situation where the state of the room returns nothing and crashes.
The prime example that exposed this was attempting to get the state of a room's second user and the history visibility event at the point in the state of the room of the creator's initial membership event. Neither of the sought events can exist at that point, hence an error.
Now will use a more tolerant way of dealing with state that can not exist