Re-expose the standalone format_event_* transforms for backwards compat#19922
Merged
Conversation
The port of event serialization to Rust (#19837) removed `format_event_raw`, `format_event_for_client_v1`, `format_event_for_client_v2` and `format_event_for_client_v2_without_room_id` from `synapse.events.utils`, but there are modules in the wild that import them from there. Reimplement them as standalone pyfunctions in Rust, operating directly on the Python dict so the original semantics are preserved exactly (in-place mutation, returning the same dict, arbitrary non-JSON values passing through, KeyError on a missing `unsigned` in the v1 format), and re-export them from `synapse.events.utils`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… hack Make clear that modules shouldn't be pulling these in — they were never part of the module API — and that they may be removed in the future. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
erikjohnston
marked this pull request as ready for review
July 7, 2026 11:38
reivilibre
approved these changes
Jul 7, 2026
| # `synapse.events.utils`) anyway. They may be removed in the future; nothing | ||
| # in Synapse itself should use them. | ||
|
|
||
| def format_event_raw(d: JsonDict) -> JsonDict: |
Contributor
There was a problem hiding this comment.
add @deprecated annotations?
Member
Author
There was a problem hiding this comment.
Hmm, that isn't introduced till 3.13. I also think we tried to figure this out previously and couldn't work out a way that worked?
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.
The port of event serialization to Rust (#19837) removed
format_event_raw,format_event_for_client_v1,format_event_for_client_v2andformat_event_for_client_v2_without_room_idfromsynapse.events.utils, but there are modules in the wild that import them from there.Reimplement them as standalone pyfunctions in Rust, operating directly on the Python dict so the original semantics are preserved exactly (in-place mutation, returning the same dict, arbitrary non-JSON values passing through, KeyError on a missing
unsignedin the v1 format), and re-export them fromsynapse.events.utils.