fix: Remove state_key: null from Seshat search results#31524
Merged
dbkr merged 4 commits intoelement-hq:developfrom Feb 5, 2026
Merged
fix: Remove state_key: null from Seshat search results#31524dbkr merged 4 commits intoelement-hq:developfrom
dbkr merged 4 commits intoelement-hq:developfrom
Conversation
dbkr
approved these changes
Dec 12, 2025
Member
dbkr
left a comment
There was a problem hiding this comment.
Great catch, thanks for the fix!
src/Searching.ts
Outdated
| for (const searchResult of localResult.results) { | ||
| const event = searchResult.result as unknown as Record<string, unknown>; | ||
| if (event && "state_key" in event && event.state_key === null) { | ||
| delete event.state_key; |
Member
There was a problem hiding this comment.
Non blocking, but if (event?.state.key === null) delete event.state_key would probably be more succinct here (if it doesn't exist it will be undefined)
Contributor
Author
There was a problem hiding this comment.
Thank you for the suggestion. I have fixed it.
Seshat includes "state_key": null for non-state events, which causes matrix-js-sdk to incorrectly treat them as state events. This prevents encrypted messages from rendering properly in search results. This fix removes the null state_key from search results and context events before passing them to the SDK.
9c51af5 to
47a6927
Compare
Member
|
Sorry, this is now failing the threshold for test coverage: would you be able to add a test to make up the 4%? |
Member
|
Thanks! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR: Remove state_key: null from Seshat search results
Summary
Seshat (local search index) incorrectly includes
"state_key": nullfor non-state events in search results. This causesmatrix-js-sdkto incorrectly treat them as state events, which prevents encrypted messages from rendering properly in search results.Changes
state_key: nullfrom main search result eventsstate_key: nullfrom context events (events_before/events_after)Files Changed
src/Searching.ts- Add post-processing to remove null state_keytest/unit-tests/Searching-test.ts- Add testsTests
Unit tests added in
test/unit-tests/Searching-test.ts:removes state_key: null from search results- Verifies thatstate_key: nullis removed from main search result events and context eventsdoes not modify events without state_key: null- Verifies that events withoutstate_keyare not accidentally modifiedRelated Issues
This is a workaround for a Seshat bug where non-state events are serialized with
state_key: nullinstead of omitting the field entirely.Checklist
public/exportedsymbols have accurate TSDoc documentation.