Skip to content

Re-expose the standalone format_event_* transforms for backwards compat#19922

Merged
erikjohnston merged 3 commits into
developfrom
erikj/format-event-compat
Jul 7, 2026
Merged

Re-expose the standalone format_event_* transforms for backwards compat#19922
erikjohnston merged 3 commits into
developfrom
erikj/format-event-compat

Conversation

@erikjohnston

Copy link
Copy Markdown
Member

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.

erikjohnston and others added 3 commits July 7, 2026 11:30
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
erikjohnston marked this pull request as ready for review July 7, 2026 11:38
@erikjohnston
erikjohnston requested a review from a team as a code owner July 7, 2026 11:38

@reivilibre reivilibre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM otherwise

# `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:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add @deprecated annotations?

@erikjohnston erikjohnston Jul 7, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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?

@erikjohnston
erikjohnston merged commit f8fefb0 into develop Jul 7, 2026
43 of 46 checks passed
@erikjohnston
erikjohnston deleted the erikj/format-event-compat branch July 7, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants