Skip to content

Conversation

@jason-famedly
Copy link
Contributor

Using the StorageController.state.get_state_for_events() function has a limitation, in that outlier events or filtered events will raise a RuntimeError. 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

This particular function is not particularly usable when early in a room
and applying a filter for events that do not exist yet
@jason-famedly jason-famedly changed the title fix: Use different state retrieval function for graceful handling of missing state fix(MSC3911): Use different state retrieval function for graceful handling of missing state Sep 17, 2025
@jason-famedly jason-famedly marked this pull request as ready for review September 17, 2025 13:30
@jason-famedly jason-famedly requested a review from a team as a code owner September 17, 2025 13:30
Copy link
Member

@nico-famedly nico-famedly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super sure, if this is the best way to handle this, but I think it is sufficient, since the media visibility checks are just in addition to already having to receive the media, so having it possibly slightly more lax is probably okay.

@nico-famedly nico-famedly merged commit f283804 into msc3911 Sep 18, 2025
20 of 23 checks passed
@nico-famedly nico-famedly deleted the jason/fixup-media-visibility branch September 18, 2025 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants