Skip to content
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

Unclear what filtering with empty arrays does #1312

Open
clokep opened this issue Oct 31, 2022 · 2 comments
Open

Unclear what filtering with empty arrays does #1312

clokep opened this issue Oct 31, 2022 · 2 comments
Labels
A-Client-Server Issues affecting the CS API clarification An area where the expected behaviour is understood, but the spec could do with being more explicit

Comments

@clokep
Copy link
Member

clokep commented Oct 31, 2022

Link to problem area: https://spec.matrix.org/v1.4/client-server-api/#_matrixclientv3useruseridfilter_eventfilter

Issue

It is unclear what providing an empty array for e.g. types or not_types would do. Is that treated as not providing the field (empirically this is what happens)?

According to tulir the proper way to filter out all event types is: {"not_types": ["*"]}

See https://matrix.to/#/!NasysSDfxKxZBzJJoE:matrix.org/$q-MFBajP8Lvnxs7r1u_AyfGtUf7spu86BUVFuhqTHXM?via=matrix.org&via=libera.chat&via=element.io.

@clokep clokep added the clarification An area where the expected behaviour is understood, but the spec could do with being more explicit label Oct 31, 2022
@turt2live turt2live added the A-Client-Server Issues affecting the CS API label Oct 31, 2022
@Benjamin-L
Copy link

My opinion is that types: [] should filter out all events, same as not_types: [ "*" ]. not_types: [] should be a no-op. This is consistent with ruma's type definitions, where not_types: [] will be (de)serialized as a missing not_types key, while types: [] is preserved as different from a missing types key.

This behavior (types: [] rejects all events, not_types: [] is no-op) is what I'm using for my filtering implementation in grapevine here.

@clokep
Copy link
Member Author

clokep commented Jun 24, 2024

I believe that matches Synapse behavior: https://github.com/element-hq/synapse/blob/805e6c9a8f703a0a774321bd0755be63dcdcc807/synapse/api/filtering.py#L467

Unsure if this was always the same or changed recently: element-hq/synapse@7e582a2

Edit: Looks like that commit didn't change the filtering logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Client-Server Issues affecting the CS API clarification An area where the expected behaviour is understood, but the spec could do with being more explicit
Projects
None yet
Development

No branches or pull requests

3 participants