-
Notifications
You must be signed in to change notification settings - Fork 417
MSC3873: event_match dotted keys #3873
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0354d87
Add proposal
Johennes 06ed1fe
Insert MSC number
Johennes cd906fc
Fix spelling
Johennes 03ddc0a
Clarifications & remove backwards compatibility.
clokep 68542ef
Mention how this blocks features.
clokep 9954b30
Fix typos.
clokep 74ae71b
Clarify tense.
clokep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # MSC3873: event_match dotted keys | ||
|
|
||
| The current specification of [`event_match`] describes the parameter | ||
| `key` as | ||
|
|
||
| > `key`: The dot-separated path of the property of the event to match, | ||
| > e.g. `content.body`. | ||
|
|
||
| It does, however, not clarify how to handle collisions such as in | ||
|
|
||
| { | ||
| "m": { "foo": "bar" }, | ||
| "m.foo": "baz" | ||
| } | ||
|
|
||
| where it is unclear which field the dot-separated path `m.foo` should | ||
| match ([#648]). | ||
|
|
||
| While collisions are often not a practical problem, the ambiguity in the | ||
| specification leads to incompatible implementations as evidenced by | ||
| [matrix-org/matrix-js-sdk#1454]. The current proposal resolves the | ||
| ambiguity by leveraging the existing solution for the same problem in | ||
| the [filter API]. | ||
|
|
||
| ## Proposal | ||
|
|
||
| The . character in the `key` parameter is changed to be exclusively | ||
| reserved for field separators. Any literal key in field names is to be | ||
| escaped using a \\. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Revisiting the example from above | ||
|
|
||
| { | ||
| "m": { "foo": "bar" }, | ||
| "m.foo": "baz" | ||
| } | ||
|
|
||
| this means that `"key": "m.foo"` unambiguously matches the nested `foo` | ||
| field. The top-level `m.foo` field in turn can be matched through | ||
| `"key": "m\.foo"`. | ||
|
|
||
| As mentioned above, this exact solution is already employed in the | ||
| [filter API]. Reusing it here, therefore, increases the | ||
| specification’s coherence. | ||
|
|
||
| ## Backwards compatibility | ||
|
|
||
| In order to provide partial backwards compatibility, implementations | ||
| should continue supporting unescaped dot-separated paths in situations | ||
| where they are collision-free. In other words, `"key": "m.foo"` should | ||
| continue matching both | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| { | ||
| "m": { "foo": "bar" }, | ||
| } | ||
|
|
||
| and | ||
|
|
||
| { | ||
| "m.foo": "baz" | ||
| } | ||
|
|
||
| but not | ||
|
|
||
| { | ||
| "m": { "foo": "bar" }, | ||
| "m.foo": "baz" | ||
| } | ||
|
|
||
| It is recommend that implementations maintain this fallback for a | ||
| certain transition period, e.g. one year, to give clients a chance to | ||
| update any affected push rules. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Potential issues | ||
|
|
||
| The proposed solution is only partially backwards compatible and will | ||
| break any push rule that relies on implicit implementation behavior | ||
| caused by the ambiguity. This is, unfortunately, unavoidable because the | ||
| very purpose of this proposal is to resolve said ambiguity. | ||
|
|
||
| ## Alternatives | ||
|
|
||
| An alternative to the current proposal are [JSON pointers]. While | ||
| being more versatile than the simplistic escaping proposed here, JSON | ||
| pointers introduce a wholly new DSL for the `key` parameter which breaks | ||
| backwards compatibility for *all* existing `event_match` conditions. | ||
|
|
||
| ## Security considerations | ||
|
|
||
| None. | ||
|
|
||
| [`event_match`]: https://spec.matrix.org/v1.3/client-server-api/#conditions-1 | ||
| [#648]: https://github.com/matrix-org/matrix-spec/issues/648 | ||
| [matrix-org/matrix-js-sdk#1454]: https://github.com/matrix-org/matrix-js-sdk/issues/1454 | ||
| [filter API]: https://spec.matrix.org/v1.3/client-server-api/#post_matrixclientv3useruseridfilter | ||
| [JSON pointers]: https://www.rfc-editor.org/rfc/rfc6901 | ||
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.
Uh oh!
There was an error while loading. Please reload this page.