Commit Graph
25963 Commits
Author SHA1 Message Date
Matthew Hodgson fe471dfcbf XXX REVERT BEFORE MERGE: drop ./tests/msc4429 from complement runs
complement main has no tests/msc4429 (matrix-org/complement#849 is
unmerged), so since 19556 merged, every complement CI run on develop
build-fails on the missing package (obscured by a gotestfmt panic on the
mid-stream module downloads). Drop the package here so this PR's CI is
meaningful; restore the line once complement#849 lands.
2026-08-07 14:14:19 +03:00
Matthew Hodgson b7f3b88a6b Merge remote-tracking branch 'origin/develop' into matthew/paginated-sync 2026-08-07 14:13:18 +03:00
Matthew Hodgson a1e9948e3c Return 400 for a syntactically invalid pos after all
Removing M_UNKNOWN_POS is about well-formed positions the server no
longer recognises; a malformed token is a plain client error like
everywhere else. Reverts part of 20feb1ef15 and keeps a test pinning
the 400.
2026-08-07 13:47:22 +03:00
Matthew Hodgson 20feb1ef15 Apply PR review: advertise org.matrix.msc4525 in /versions, tolerate malformed pos, protect cold-start drain, fix total_rooms
- /versions now advertises org.matrix.msc4525, honouring both the global
  flag and the per-user experimental feature (as Erik requested inline).
- An unparsable pos no longer 400s: it is treated like an unrecognised
  one and the connection starts afresh (MSC4525 has no client error
  path).
- The aging lane now also reserves page slots for never-sent rooms, so
  continuous traffic in already-delivered rooms can't stall the initial
  drain indefinitely.
- total_rooms is counted before partial-state filtering so cold-start
  progress reporting isn't understated.
2026-08-07 13:38:08 +03:00
Matthew Hodgson 318029506c Namespace paginated-sync classes, types and tests with an MSC4525 prefix
Pure rename (plus the test module moving to
test_msc4525_paginated_sync.py) to make the experiment easy to grep,
remove or merge later.
2026-08-07 13:27:48 +03:00
Matthew Hodgson eb83f52f9b Document msc4525 in the admin experimental-features API 2026-08-07 13:27:48 +03:00
Matthew Hodgson c15d8cc5b1 Apply review nits: hoist bg-jobs check, drop redundant intersection, omit total_rooms when unknown, conn_id caveat, drop stray .gitignore hunk
Also adds a test for the aging-lane fairness path.
2026-08-07 13:25:33 +03:00
Matthew Hodgson 360b033178 Gate the paginated sync endpoint per user, disabled by default
Add MSC4525 to the per-user ExperimentalFeature registry: the servlet is
always registered but 404s unless the feature is enabled globally
(msc4525_enabled) or for the requesting user via the admin
experimental-features API.
2026-08-07 13:24:05 +03:00
Matthew Hodgson 8ec2cde02d Wake rooms into the page for receipt and account-data updates
Candidates were derived purely from the event stream, so a read receipt
(or room account data change) in an otherwise quiet room was deferred
until someone spoke in it. Rooms with undelivered receipt/account-data
changes - tracked PREVIOUSLY on the per-connection stream maps, or with
activity in the token range - now count as candidates when the relevant
extension is enabled: the room wakes into the page (usually as an empty,
filtered-out entry) and the extension delivers the data.
2026-08-07 13:23:03 +03:00
Matthew Hodgson 9b3f1f5816 Fix $LAZY member state on incremental paginated sync
With room-config tracking off, prev_room_sync_config was always None, so
the lazy-member accounting in get_room_sync_data never ran and incremental
responses were state-deltas-only: a timeline sender's membership that the
connection had never seen was silently omitted. Since required_state is
immutable per connection, treat the previous config as the current one,
which reduces _required_state_changes to exactly the lazy-member
bookkeeping.
2026-08-07 13:21:08 +03:00
Matthew Hodgson 7c9fbc49f9 Type the connection store against the config subset it uses
The store only needs user/requester/conn_id from the sync config, and is
shared between sliding sync and paginated sync (MSC4525), so type its
methods with a Protocol both configs satisfy instead of SlidingSyncConfig
(fixes the mypy failure on PaginatedSyncConfig at the
get_and_clear_connection_positions call site, and drops the now-redundant
ignore on record_new_state).
2026-08-07 03:26:09 +03:00
Matthew Hodgson b395a56a40 Retrigger CI after the GitHub Actions outage 2026-08-07 03:08:59 +03:00
Matthew Hodgson 1ad3eebd6e Match the base signature in PaginatedSyncExtensionHandler
The override must not narrow the base method's parameter types.
2026-08-07 00:47:19 +03:00
Matthew Hodgson 7267d29765 Add changelog 2026-08-07 00:45:07 +03:00
Matthew Hodgson 0b593cdc85 Rename to the allocated MSC4525 identifiers
Endpoint /_matrix/client/unstable/org.matrix.msc4525/sync, config flag
experimental.msc4525_enabled, docs updated.
2026-08-07 00:36:37 +03:00
Matthew Hodgson 369428eaba Paginated sync: fold in further simplifications
- No M_UNKNOWN_POS: an unrecognised pos is treated as absent (nothing
  trusted from the token); the connection starts afresh and rooms come
  down as never-sent. Clients have no error path.
- required_state is immutable per connection and always taken from the
  current request: room configs are no longer persisted or diffed
  (track_room_configs flag, off for paginated sync).
- num_live dropped from the wire (derivable: previously-sent rooms only
  receive live events, initial rooms are all-historical).
- Extension lists/rooms scoping ignored: an enabled extension applies
  to the rooms in the response (PaginatedSyncExtensionHandler).

Tests: unknown-pos-starts-afresh, extensions-without-scoping, num_live
absence; sliding sync suites unaffected (174 still green).

Also gitignore localtest/, the local validation server's scratch dir.
2026-08-06 23:56:44 +03:00
Matthew Hodgson be540f9c05 Add tests for the Paginated Sync endpoint
Covers initial-sync paging + drain (pending/total_rooms, most-recent
first, no duplication or loss), per-room gapping (limited + prev_batch,
only the newest limit events), incremental backlog paging, history
semantics for never-sent rooms, and top-level required_state.
2026-08-06 22:34:32 +03:00
Matthew Hodgson 7d5f90884a Add Paginated Sync (MSC TBD): a lists-less dialect of Simplified Sliding Sync
New unstable endpoint POST /_matrix/client/unstable/org.matrix.paginated_sync/sync
behind experimental.paginated_sync_enabled. The client sends page_size /
limit / history + a single top-level required_state; the server returns
the changed rooms (most recently active first, at most page_size of
them, at most limit new events each with an explicit per-room gap
beyond), plus pending (rooms that did not fit) and total_rooms.

The implementation is deliberately a thin layer over sliding sync:
PaginatedSyncHandler subclasses SlidingSyncHandler (room data fetch,
extensions, connection store and notifier integration are shared), the
servlet subclasses SlidingSyncRestServlet (room/extension serialisation
shared), and the paging cursor is the existing NEVER/PREVIOUSLY/LIVE
per-connection room tracking - candidates that don't fit the page are
recorded unsent and picked up next request. Fairness: when more rooms
are pending than fit, a quarter of the page is reserved for the rooms
whose undelivered updates are oldest. The expanded-timeline hack is
disabled for this endpoint (history is /messages' job).
2026-08-06 22:31:44 +03:00
Erik Johnston e3d9b15cc6 Cleanup cancelled tasks as well (#20068)
Rather than just completed and failed tasks.
2026-08-06 18:11:32 +01:00
c5f02a9313 Introduce support for MSC4429: Profile Updates for Legacy Sync (#19556)
Implements support for [MSC4429: Profile Updates for Legacy
Sync](https://github.com/matrix-org/matrix-spec-proposals/pull/4429).

Paired with https://github.com/matrix-org/complement/pull/849 and
https://github.com/matrix-org/sytest/tree/anoa/msc4429

Tracking issue for removing unstable identifiers in Synapse:
https://github.com/element-hq/synapse/issues/19891
Further improvements tracked in:
https://github.com/element-hq/synapse/issues/19981

---------

Co-authored-by: Half-Shot <will@half-shot.uk>
Co-authored-by: Jason Robinson <jasonr@element.io>
Co-authored-by: Olivier 'reivilibre' <oliverw@element.io>
2026-08-06 15:35:07 +01:00
dependabot[bot] 556154848c Bump gitpython from 3.1.54 to 3.1.57 (#20046)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-06 10:11:56 +00:00
dependabot[bot] 701baedbea Bump actions/checkout from 7.0.0 to 7.0.1 in the minor-and-patches group (#20043)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-06 10:09:50 +00:00
dependabot[bot] 98a0cae3c3 Bump the patches group with 6 updates (#20042)
Signed-off-by: dependabot[bot] <support@github.com>
2026-08-06 10:09:27 +00:00
Olivier 'reivilibre 320265f09b Remove broken DROP statements for SQLite in make_full_schema script. (#20028)
Broken out of #20027 because I'd like to have it land first.

> It seems a lot of time in our trial tests goes towards setting up the
database. (The same is probably true of Complement too)
> 
> We haven't done a full schema for about 20 schema versions, so no
surprise!
> 
> As a result, I want to produce a full schema soon.

When running `make_full_schema.sh`, these drop statements now cause the
error:

```
Parse error near line 2: table event_search_content may not be dropped
Parse error near line 3: table event_search_segments may not be dropped
Parse error near line 4: table event_search_segdir may not be dropped
Parse error near line 5: table event_search_docsize may not be dropped
Parse error near line 6: table event_search_stat may not be dropped
Parse error near line 7: table user_directory_search_content may not be dropped
Parse error near line 8: table user_directory_search_segments may not be dropped
Parse error near line 9: table user_directory_search_segdir may not be dropped
Parse error near line 10: table user_directory_search_docsize may not be dropped
Parse error near line 11: table user_directory_search_stat may not be dropped
```

It seems SQLite has cracked down on code that edits the internal tables.

Because SQLite dumps the schema with `CREATE TABLE IF NOT EXISTS` for
these virtual tables, it's harmless to leave them in the schema dump.

---------

Signed-off-by: Olivier 'reivilibre' <oliverw@matrix.org>
2026-08-06 10:15:21 +01:00
Eric Eastwood 3cb6c3484d Document how to capture a JSON snapshot of a Grafana dashboard (#20048)
To make it easy to share to people and aid in debugging when they run into
performance issues.

Unfortunately, the Grafana UI doesn't make the export or import steps
easy so it involves some manual Grafana API calls.

As first explored in
https://github.com/element-hq/synapse-rust-apps/pull/397
2026-08-05 11:11:30 -05:00
Eric Eastwood c9da03e576 Merge branch 'master' into develop 2026-08-04 14:12:18 -05:00
Eric Eastwood 7a3e98b6f7 1.158.0 v1.158.0 2026-08-04 12:53:51 -05:00
Eric Eastwood 5b29f8160e Drop support for Ubuntu 25.10 'Questing Quokka', add support for Ubuntu 26.04 'Resolute Raccoon' (#20039)
Fix https://github.com/element-hq/synapse/issues/20031

### Dev notes

 - https://endoflife.date/ubuntu
 - https://endoflife.date/debian
 - https://endoflife.date/python

Finding Python version on distros:

 - https://packages.debian.org/trixie/python3
 - https://packages.ubuntu.com/resolute/python3
2026-08-04 09:12:10 -05:00
Eric Eastwood 2c8bf9a3ab Drop support for Ubuntu 25.10 'Questing Quokka', add support for Ubuntu 26.04 'Resolute Raccoon' (#20039)
Fix https://github.com/element-hq/synapse/issues/20031

### Dev notes

 - https://endoflife.date/ubuntu
 - https://endoflife.date/debian
 - https://endoflife.date/python

Finding Python version on distros:

 - https://packages.debian.org/trixie/python3
 - https://packages.ubuntu.com/resolute/python3
2026-08-04 09:08:19 -05:00
Jason Little 415a869f1f fix RemoteJoinHelper to handle v12 rooms (#20021)
While preparing for the default room version change to "12", the new
tests for
[FederationJoinUpgradedRoomTestCase](https://github.com/element-hq/synapse/blob/36664cac4fdec38993c68078cd9a82452b56dca7/tests/federation/test_federation_join_upgraded_room.py#L44)
were unable to handle creation events inside of the manufactured
`auth_events` sections. All of these tests fail.

Related to https://github.com/element-hq/synapse/pull/20015 as another
recent fix to `RemoteJoinHelper`


### Testing strategy

To test, I recommend changing the `DEFAULT_ROOM_VERSION` in [the
`server.py` config
file](https://github.com/element-hq/synapse/blob/36664cac4fdec38993c68078cd9a82452b56dca7/synapse/config/server.py#L179)
to `"12"`, then running `poetry run trial
tests.federation.test_federation_join_upgraded_room.FederationJoinUpgradedRoomTestCase`
for these selective tests. Alternatively, creating the
`default_config()` for the `TestCase` in question to set the default
room version, but that is more work.
2026-08-03 13:47:26 -05:00
Eric Eastwood f61950d54d Fix release announcement to link to correct release branch of changelog (#20023)
Without this change, it was linking to `develop` as we were on the
`develop` branch because of the previous `merge-back` step at this point
in the release process.

Follow-up to https://github.com/element-hq/synapse/pull/19984 as this
was an oversight and I assumed we would still be on the `release-v1.158`
branch by that point.
2026-07-31 13:58:20 -05:00
Eric Eastwood e4644ae2b9 Remove duplicated punctuation v1.158.0rc1 2026-07-30 11:03:39 -05:00
Eric Eastwood 305e590bea Link and use canonical API name 2026-07-30 10:55:30 -05:00
Eric Eastwood 446bc852de Split #19898 changelog across two points 2026-07-30 10:52:13 -05:00
Eric Eastwood ade9176934 1.158.0rc1 2026-07-30 09:54:20 -05:00
Olivier 'reivilibre 36664cac4f Add Module API hooks that notify modules when events are delivered over federation. (#20019)
Closes: https://github.com/element-hq/synapse/issues/19904

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-07-30 12:32:27 +01:00
Eric Eastwood 897f68b3c2 Fix assertIncludes printing None at the end of the message (#20020) 2026-07-29 13:30:39 -05:00
Eric Eastwood fba14358a7 Fix RemoteJoinHelper signing events with the default room version (room version mismatch) (#20015)
Fix `RemoteJoinHelper` signing events with mismatched room version
compared to the `room_version` arg. The default room version on
`develop` is `11` but the `RemoteJoinHelper` `room_version` arg defaults
to `10` (room version mismatch). This mismatch wasn't present where this
fix was developed
(https://github.com/element-hq/synapse-private/pull/136) as the default
room version was only recently bumped to `11` via
https://github.com/element-hq/synapse/pull/18680 (not even in a release
yet).

Fixes the CI being broken on `develop` :x::

```
[ERROR]
Traceback (most recent call last):
  File "/home/runner/work/synapse/synapse/tests/federation/test_federation_join_upgraded_room.py", line 298, in test_no_transfer_when_tombstone_does_not_match
    join_helper.join(local_user_id, local_user_tok)
  File "/home/runner/work/synapse/synapse/tests/federation/_remote_join.py", line 350, in join
    self._test_case.helper.join(remote_room_id, local_user_id, tok=local_user_tok)
  File "/home/runner/work/synapse/synapse/tests/rest/client/utils.py", line 195, in join
    return self.change_membership(
  File "/home/runner/work/synapse/synapse/tests/rest/client/utils.py", line 333, in change_membership
    assert channel.code == expect_code, (
builtins.AssertionError: Expected: 200, got: 400, PUT /_matrix/client/r0/rooms/!remote-room:other.example.com/state/m.room.member/@user1:test?access_token=syt_dXNlcjE_JSEarRndiAGqtydnrdLn_33qlLD -> resp: b'{"errcode":"M_UNKNOWN","error":"No create event in state"}'

tests.federation.test_federation_join_upgraded_room.FederationJoinUpgradedRoomTestCase.test_no_transfer_when_tombstone_does_not_match
```

These tests were originally introduced
https://github.com/element-hq/synapse-private/pull/136 (developed
private as this was part of the Synapse security release) and introduced
into the public codebase via
https://github.com/element-hq/synapse/commit/cbc6934821aab314506c5957223c60c74eeda091
2026-07-29 10:32:41 -05:00
dependabot[bot] e3715b24fb Bump the patches group with 2 updates (#20012)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-29 09:30:21 +00:00
dependabot[bot] 41c41d2c12 Bump quinn-proto from 0.11.14 to 0.11.16 (#20010)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-29 09:30:01 +00:00
Eric Eastwood 1a1af7b622 Link to changelog instead of duplicating content in the tag/release (#19984)
This means we can point to a single source of truth instead of
duplicating the content to the tag and GitHub release. Less to manage
and worry about when you make some updates to the changelog (maintenance
burden). We also get to avoid the content sitting in the vendor lock-in
GitHub releases.

We point to
`https://github.com/element-hq/synapse/blob/{repo.active_branch.name}/CHANGES.md`
as it will have the relevant changelog entry at the top and won't change
as we archive releases on `develop`. Even for RC releases after the main
release goes out, the entry will still be towards the top. We could try
to get the heading anchor for the specific section but I thought that it
wasn't necessary (nice but more complex).
2026-07-28 15:44:26 -05:00
dependabot[bot] 5d55a05f8e Bump regex from 1.12.4 to 1.13.0 (#20013)
Signed-off-by: dependabot[bot] <support@github.com>
2026-07-28 14:02:43 +00:00
Olivier 'reivilibre 9761f9bc42 Merge branch 'master' into develop 2026-07-28 14:39:05 +01:00
Olivier 'reivilibre 0c709bbb78 1.157.2 v1.157.2 2026-07-28 14:02:12 +01:00
Olivier 'reivilibre 0a2456fef3 Validate room name, avatar and heroes' profile fields before sending down sliding sync as trusted fields
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-jhcg-5392-5mjw
Fixes: https://github.com/matrix-org/internal-config/issues/1751

I introduce some stricter JSON types that don't break down to `Any` — it seems these have become possible since our last attempt.
(I'm pretty sure mypy wouldn't let you do this a few years ago.)
Our `dict[str, Any]` type is such a footgun. I'd like to spread this out further, but will do so after the security release.

I then use these stricter JSON types on everything the sliding sync handler pulls out of `event.content` and therefore get forced into a bare minimum level of validation, by the type checker.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/151
2026-07-28 13:58:06 +01:00
Olivier 'reivilibre c3adee3509 Restrict what errors we forward to clients from federation and policy servers
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-95fh-hv8c-chvq
Fixes: https://github.com/matrix-org/internal-config/issues/1721

https://github.com/element-hq/synapse-private/pull/158 is the end goal, I think

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/159
2026-07-28 13:58:06 +01:00
Olivier 'reivilibre 44216bf2b6 Limit the size of push rules
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-fp53-rw9v-hcf9
Fixes: https://github.com/matrix-org/internal-config/issues/1071

Because this is an out-of-spec limit and could break someone's workflow on release day, I've opted to make it configurable.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/149
2026-07-28 13:58:06 +01:00
Olivier 'reivilibre 4f8037ab59 Anchor the ends of our path patterns to prevent path traversal vulnerabilities
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-hgcg-p9gx-fq5f
Fixes: https://github.com/element-hq/backend-internal/issues/217 -> https://github.com/matrix-org/internal-config/issues/1760

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/146
2026-07-28 13:58:06 +01:00
Olivier 'reivilibreandEric Eastwood cbc6934821 Prevent theft of room aliases via remote join to room with illegitimate predecessor
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-cjh7-rcpx-xpf8
Fixes: https://github.com/matrix-org/internal-config/issues/1729

---------

Co-authored-by: Eric Eastwood <erice@element.io>
Reviewed-on: https://github.com/element-hq/synapse-private/pull/136
2026-07-28 13:58:06 +01:00
Olivier 'reivilibre 68139e5234 Add missing 'event in expected room' check on /event_auth
Fixes: https://github.com/element-hq/synapse/security/advisories/GHSA-qcjr-46gf-7f4r
Fixes: https://github.com/matrix-org/internal-config/issues/1714

The `/event_auth` endpoint could be tricked to give you the auth chain for an event in a foreign room,
because it trusted the requester to provide the correct `room_id` for the event.

Now we pass the `room_id` through all the way to `get_event`'s `check_room_id`, which (correctly IMO) treats mismatches as unknown events (seems correct as it prevents divulging what events we know about).

The `test_event_auth_wrong_room_returns_404` test failed before the fix.

-----

Reviewed-on: https://github.com/element-hq/synapse-private/pull/147
2026-07-28 13:58:06 +01:00