9217 Commits

Author SHA1 Message Date
Erik Johnston
0549307198 Revert "Limit outgoing to_device EDU size to 65536" (#19614)
Reverts element-hq/synapse#18416


Unfortunately, this causes failures on `/sendToDevice` endpoint in
normal circumstances. If a single user has, say, a hundred devices then
we easily go over the limit. This blocks message sending entirely in
encrypted rooms.

cc @MadLittleMods @MatMaul
2026-03-27 10:53:16 +00:00
Erik Johnston
539f708f32 Remove redacted_because from internal unsigned. (#19581)
This is a simplification so that `unsigned` only includes "simple"
values, to make it easier to port to Rust.

Reviewable commit-by-commit

Summary:

1. **Add `recheck` column to `redactions` table**
   
A new boolean `recheck` column (default true) is added to the
`redactions` table. This captures whether a redaction needs its sender
domain checked at read time — required for room v3+ where redactions are
accepted speculatively and later validated. When persisting a new
redaction, `recheck` is set directly from
`event.internal_metadata.need_to_check_redaction()`.
     
It's fine if initially we recheck all redactions, as it only results in
a little more CPU overhead (as we always pull out the redaction event
regardless).
                                                      
2. **Backfill `recheck` via background update**
   
A background update (`redactions_recheck`) backfills the new column for
existing rows by reading `recheck_redaction` from each event's
`internal_metadata` JSON. This avoids loading full event objects by
reading `event_json` directly via a SQL JOIN.
                              
3. **Don't fetch confirmed redaction events from the DB**
                              
Previously, when loading events, Synapse recursively fetched all
redaction events regardless of whether they needed domain rechecking.
Now `_fetch_event_rows` reads the `recheck` column and splits redactions
into two lists:
        - `unconfirmed_redactions` — need fetching and domain validation
- `confirmed_redactions` — already validated, applied directly without
fetching the event
      
This avoids unnecessary DB reads for the common case of
already-confirmed redactions.
4. **Move `redacted_because` population to `EventClientSerializer`**
Previously, `redacted_because` (the full redaction event object) was
stored in `event.unsigned` at DB fetch time, coupling storage-layer code
to client serialization concerns. This is removed from
`_maybe_redact_event_row` and moved into
`EventClientSerializer.serialize_event`, which fetches the redaction
event on demand. The storage layer now only sets
`unsigned["redacted_by"]` (the redaction event ID).
5. **Always use `EventClientSerializer`**
   
The standalone `serialize_event` function was made private
(`_serialize_event`). All external callers — `rest/client/room.py`,
`rest/admin/events.py, appservice/api.py`, and `tests` — were updated to
use `EventClientSerializer.serialize_event` / `serialize_events`,
ensuring
  `redacted_because` is always populated correctly via the serializer.
6. **Batch-fetch redaction events in `serialize_events`**
   
`serialize_events` now collects all `redacted_by` IDs from the event
batch upfront and fetches them in a single `get_events` call, passing
the result as a `redaction_map` to each `serialize_event` call. This
reduces N individual DB round-trips to one when serializing a batch of
events that includes redacted events.

---------

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-26 09:18:08 +00:00
Erik Johnston
f545aa4f33 Port RoomVersion to Rust (#19589)
Principally so that we can share the same room version configuration
between Python and Rust.

For the most part, this is a direct port. Some special handling has had
to go into `KNOWN_ROOM_VERSIONS` so that it can be sensibly shared
between Python and Rust, since we do update it during config parsing.

---------

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-26 09:17:31 +00:00
Eric Eastwood
f2b325f86c Demystify and deprecate HomeserverTestCase.pump() (Twisted reactor/clock) (#19602)
Spawning from
https://github.com/element-hq/synapse/pull/18416#discussion_r2967619735
2026-03-25 15:33:17 -05:00
Olivier 'reivilibre
6c7e05fe20 Allow Synapse to start up even when discovery fails for an OpenID Connect provider. (#19509)
Fixes: #8088

Previously we would perform OIDC discovery on startup,
which involves making HTTP requests to the identity provider(s).

If that took a long time, we would block startup.

If that failed, we would crash startup.

This commit:

- makes the loading happen in the background on startup
- makes an error in the 'preload' non-fatal (though it logs at CRITICAL
for visibility)
- adds a templated error page to show on failed redirects (for
unavailable providers), as otherwise you get a JSON response in your
navigator.
- This involves introducing 2 new exception types to mark other
exceptions and keep the error handling fine-grained.

The machinery was already there to load-on-demand the discovery config,
so when the identity provider
comes back up, the discovery is reattempted and login can succeed.

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-03-24 17:39:21 +00:00
Mathieu Velten
7fad50fd76 Limit outgoing to_device EDU size to 65536 (#18416)
If a set of messages exceeds this limit, the messages are split
across several EDUs.

Fix #17035 (should)

There is currently [no official specced limit for
EDUs](https://github.com/matrix-org/matrix-spec/issues/807), but the
consensus seems to be that it would be useful to have one to avoid this
bug by bounding the transaction size.

As a side effect it also limits the size of a single to-device message
to a bit less than 65536.

This should probably be added to the spec similarly to the [message size
limit.](https://spec.matrix.org/v1.14/client-server-api/#size-limits)

Spec PR: https://github.com/matrix-org/matrix-spec/pull/2340

---------

Co-authored-by: mcalinghee <mcalinghee.dev@gmail.com>
Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
2026-03-24 11:22:11 -05:00
Andrew Morgan
713aa7ebf0 Hide successful, skipped Complement tests in the CI (#19590)
Co-authored-by: Eric Eastwood <erice@element.io>
2026-03-23 15:16:23 +00:00
Travis Ralston
40d699b1d4 Stable support for MSC4284 policy servers (#19503)
Fixes https://github.com/element-hq/synapse/issues/19494

MSC4284 policy servers

This:
* removes the old `/check` (recommendation) support because it's from an
older design. Policy servers should have updated to `/sign` by now. We
also remove optionality around the policy server's public key because it
was only optional to support `/check`.
* supports the stable `m.room.policy` state event and `/sign` endpoints,
falling back to unstable if required. Note the changes between unstable
and stable:
* Stable `/sign` uses errors instead of an empty signatures block to
indicate refusal.
* Stable `m.room.policy` nests the public key in an object with explicit
key algorithm (always ed25519 for now)
* does *not* introduce tests that the above fallback to unstable works.
If it breaks, we're not going to be sad about an early transition. Tests
can be added upon request, though.
* fixes a bug where the policy server was asked to sign policy server
state events (the events were correctly skipped in `is_event_allowed`,
but `ask_policy_server_to_sign_event` didn't do the same).
* fixes a bug where the original event sender's signature can be deleted
if the sending server is the same as the policy server.
* proxies Matrix-shaped errors from the policy server to the
Client-Server API as `SynapseError`s (a new capability of the stable
API).


Membership event handling (from the issue) is expected to be a different
PR due to the size of changes involved (tracked by
https://github.com/element-hq/synapse/issues/19587).



### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: turt2live <1190097+turt2live@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Eric Eastwood <madlittlemods@gmail.com>
2026-03-20 19:34:26 +00:00
Hugh Nimmo-Smith
b4282b82d0 Updates for experimental MSC4388 support (sign-in with QR code) (#19573) 2026-03-20 16:33:43 +00:00
Andrew Morgan
2c412ba24a complement.sh: ensure old complement checkout files are deleted; remove -N wget flag (#19592) 2026-03-20 16:30:03 +00:00
Andrew Morgan
9edbf56969 Prevent sending registration emails if registration is disabled (#19585) 2026-03-19 12:52:40 +00:00
Quentin Gliech
edf5ce277a Allow using HTTP/2 over plaintext when introspecting tokens with MAS (#19586) 2026-03-18 19:47:17 +01:00
Travis Ralston
261bfb786f Fix zeroing out remote quarantined media count (#19559)
Just something I noticed while working on
https://github.com/element-hq/synapse/pull/19558

We start the function by setting `total_media_quarantined` to zero, then
we do work on the `media_ids`, add the number affected, zero it out
(**bug**), do work on `hashes`, add the number of affected rows, then
return `total_media_quarantined`.

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
2026-03-18 09:50:09 -06:00
Tulir Asokan
8201e58767 Update and stabilize mutual rooms support (MSC2666) (#19511)
Updates the error codes to match MSC2666 changes (user ID query param
validation + proper errcode for requesting rooms with self), added the
new `count` field, and stabilized the endpoint.
2026-03-18 14:29:36 +00:00
Eric Eastwood
3d960d88b3 Add MSC3820 comment context to RoomVersion attributes (#19577)
Spawning from
https://github.com/element-hq/synapse/pull/19424#discussion_r2855303614
2026-03-18 07:53:13 -05:00
Olivier 'reivilibre
0d4accb0a6 Remove support for MSC3852: Expose user agent information on Device as the MSC was closed. (#19430)
Fixes: #14836

Discovered whilst looking at the state of MSCs in Synapse.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-03-17 17:08:04 +00:00
Eric Eastwood
d65ef848eb Fix Build and push complement image CI job not having Poetry for complement.sh (#19578)
 `Build and push complement image`,
https://github.com/element-hq/synapse/actions/runs/23176317296/job/67339146082
```
scripts-dev/complement.sh: line 227: poetry: command not found
```

Follow-up to https://github.com/element-hq/synapse/pull/19523

This regressed in https://github.com/element-hq/synapse/pull/19476


### Testing strategy

1. Visit
https://github.com/element-hq/synapse/actions/workflows/push_complement_image.yml
 1. **Run workflow**:
- **Use workflow from:**
`madlittlemods/fix-complement-push-image-ci-job-poetry`
     - **Branch:** `develop`
 1. Wait for CI to run and pass 
2026-03-17 10:51:53 -05:00
Quentin Gliech
7d8e8747ea 1.150.0rc1 2026-03-17 15:56:55 +01:00
Quentin Gliech
6a63f0dcd7 Migrate dev dependencies to PEP 735 dependency groups (#19490)
This moves the dev dependencies to PEP 735 dependency groups, to help us
move to standard project metadata, which will help us moving to `uv`
(#19566)

This requires poetry 2.2.0
2026-03-17 14:45:28 +00:00
Eric Eastwood
8ad7e8af81 Add some light labels to the Processed request logs (#19548)
It's pretty hard to remember the order of all of these ambiguous
numbers. I assume they're not totally labeled already to cut down on the
length when scanning with your eyes. This just adds a few hints of what
each grouping is.

Spawning from [staring at some Synapse
logs](https://github.com/element-hq/matrix-hosted/issues/10631) and
cross-referencing the Synapse source code over and over.
2026-03-17 09:43:05 -05:00
Andrew Ferrazzutti
8a6d9a8d45 Admin API docs: use consistent path param syntax (#19307)
Always use `/<param>` instead of sometimes using `/$param`

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
2026-03-17 15:36:07 +01:00
Eric Eastwood
6254e009bb Fix Build and push complement image CI job pointing to non-existent image (#19523)

https://github.com/element-hq/synapse/actions/runs/22609655282/job/65509315002#step:8:39
```
Error response from daemon: No such image: complement-synapse:latest
```

Regressed in
https://github.com/element-hq/synapse/pull/19475#discussion_r2823157623
where we updated `complement.sh` to build `localhost/complement-synapse`
instead of `complement-synapse`.
2026-03-16 21:56:16 -05:00
Olivier 'reivilibre
3aa948c50c When Matrix Authentication Service (MAS) integration is enabled, allow MAS to set the user locked status in Synapse. (#19554)
Companion PR:
https://github.com/element-hq/matrix-authentication-service/pull/5550
to 1) send this flag
and 2) provision users proactively when their lock status changes.

---

Currently Synapse and MAS have two independent user lock
implementations. This PR makes it so that MAS can push its lock status
to Synapse when 'provisioning' the user.

Having the lock status in Synapse is useful for removing users from the
user directory
when they are locked.

There is otherwise no authentication requirement to have it in Synapse;
the enforcement is done
by MAS at token introspection time.

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-03-16 18:27:54 +00:00
Andrew Ferrazzutti
c0924fbbd8 MSC4140: put delay_id in unsigned data for sender (#19479)
Implements
49b200dcc1
2026-03-16 16:29:42 +00:00
Quentin Gliech
4c475dcd7a Allow the caching of the /versions and /auth_metadata endpoints (#19530)
Can be reviewed commit by commit.

This sets caching headers on the /versions and /auth_metadata endpoints
to:

- allow clients to cache the response for up to 10 minutes
(`max-age=600`)
- allow proxies to cache the response for up to an hour
(`s-maxage=3600`)
- make proxies serve stale response for up to an hour (`s-maxage=3600`)
but make them refresh their response after 10 minutes
(`stale-while-revalidate=600`) so that we always have a snappy response
to client, but also have fresh responses most of the time
- only cache the response for unauthenticated requests on /versions
(`Vary: Authorization`)

I'm not too worried about the 1h TTL on the proxy side, as with the
`stale-while-revalidate` directive, one just needs to do two requests
after 10 minutes to get a fresh response from the cache.

The reason we want this, is that clients usually load this right away,
leading to a lot of traffic from people just loading the Element Web
login screen with the default config. This is currently routed to
`client_readers` on matrix.org (and ESS) which can be overwhelmed for
other reasons, leading to slow response times on those endpoints (3s+).

Overwhelmed workers shouldn't prevent people from logging in, and
shouldn't result in a long loading spinner in clients. This PR allows
caching proxies (like Cloudflare) to publicly cache the unauthenticated
response of those two endpoints and make it load quicker, reducing
server load as well.
2026-03-12 17:11:09 +00:00
Quentin Gliech
8d03a4df11 Avoid re-computing the event ID when cloning events. (#19527)
`event_id` is a lazily-computed property on events, as it's a hash of
the event content on room version 3 and later. The reason we do this is
that it helps finding database inconsistencies by not trusting the event
ID we got from the database.

The thing is, when we clone events (to return them through /sync or
/messages for example) we don't copy the computed hash if we already
computed it, duplicating the work. This copies the internal `_event_id`
property.
2026-03-12 15:17:13 +01:00
Eric Eastwood
e30001883c Add in-repo Complement test to sanity check Synapse version matches git checkout (#19476)
This way we actually detect problems like
https://github.com/element-hq/synapse/pull/19475 as they happen instead
of being invisible until something breaks.

Sanity check that Complement is testing against your code changes
(whether it be local or from the PR in CI).

```
COMPLEMENT_DIR=../complement ./scripts-dev/complement.sh --in-repo -run TestSynapseVersion
```
2026-03-11 15:30:32 -05:00
Olivier 'reivilibre
ae239280cb Fix a bug introduced in v1.26.0 that caused deactivated, erased users to not be removed from the user directory. (#19542)
Fixes: #19540

Fixes: #16290 (side effect of the proposed fix)

Closes: #12804 (side effect of the proposed fix)

Introduced in: https://github.com/matrix-org/synapse/pull/8932

---

This PR is a relatively simple simplification of the profile change on
deactivation that appears to remove multiple bugs.

This PR's **primary motivating fix** is #19540: when a user is
deactivated and erased, they would be kept in the user directory. This
bug appears to have been here since #8932 (previously
https://github.com/matrix-org/synapse/pull/8932) (v1.26.0).
The root cause of this bug is that after removing the user from the user
directory, we would immediately update their displayname and avatar to
empty strings (one at a time), which re-inserts
the user into the user directory.

With this PR, we now delete the entire `profiles` row upon user erasure,
which is cleaner (from a 'your database goes back to zero after
deactivating and erasing a user' point of view) and
only needs one database operation (instead of doing displayname then
avatar).

With this PR, we also no longer send the 2 (deferred) `m.room.member`
`join` events to every room to propagate the displayname and avatar_url
changes.
This is good for two reasons:

- the user is about to get parted from those rooms anyway, so this
reduces the number of state events sent per room from 3 to 1. (More
efficient for us in the moment and leaves less litter in the room DAG.)
- it is possible for the displayname/avatar update to be sent **after**
the user parting, which seems as though it could trigger the user to be
re-joined to a public room.
(With that said, although this sounds vaguely familiar in my lossy
memory, I can't find a ticket that actually describes this bug, so this
might be fictional. Edit: #16290 seems to describe this, although the
title is misleading.)

Additionally, as a side effect of the proposed fix (deleting the
`profiles` row), this PR also now deletes custom profile fields upon
user erasure, which is a new feature/bugfix (not sure which) in its own
right.
I do not see a ticket that corresponds to this feature gap, possibly
because custom profile fields are still a niche feature without
mainstream support (to the best of my knowledge).

Tests are included for the primary bugfix and for the cleanup of custom
profile fields.


### `set_displayname` module API change

This change includes a minor _technically_-breaking change to the module
API.
The change concerns `set_displayname` which is exposed to the module API
with a `deactivation: bool = False` flag, matching the internal handler
method it wraps.
I suspect that this is a mistake caused by overly-faithfully piping
through the args from the wrapped method (this Module API was introduced
in
https://github.com/matrix-org/synapse/pull/14629/changes#diff-0b449f6f95672437cf04f0b5512572b4a6a729d2759c438b7c206ea249619885R1592).
The linked PR did the same for `by_admin` originally before it was
changed.

The `deactivation` flag's only purpose is to be piped through to other
Module API callbacks when a module has registered to be notified about
profile changes.
My claim is that it makes no sense for the Module API to have this flag
because it is not the one doing the deactivation, thus it should never
be in a position to set this to `True`.
My proposed change keeps the flag (for function signature
compatibility), but turns it into a no-op (with a `ERROR` log when it's
set to True by the module).

The Module API callback notifying of the module-caused displayname
change will therefore now always have `deactivation = False`.

*Discussed in
[`#synapse-dev:matrix.org`](https://matrix.to/#/!i5D5LLct_DYG-4hQprLzrxdbZ580U9UB6AEgFnk6rZQ/$1f8N6G_EJUI_I_LvplnVAF2UFZTw_FzgsPfB6pbcPKk?via=element.io&via=matrix.org&via=beeper.com)*

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-03-11 15:38:45 +00:00
Olivier 'reivilibre
6e1ac551f4 Expose MSC4354 Sticky Events over the legacy (v3) /sync API. (#19487)
Follows: #19365

Part of: MSC4354 whose experimental feature tracking issue is #19409

Partially supersedes: #18968

---------

Signed-off-by: Olivier 'reivilibre' <oliverw@matrix.org>
2026-03-10 10:39:39 +00:00
Quentin Gliech
16125cecd2 Remove the optional systemd-python dependency (#19491)
Summary
- drop the `systemd` extra from `pyproject.toml` and the
`systemd-python` optional dependency
- this means we don't ship the journald log handler, so it clarifies the
docs how to install that in the venv
- ensure the Debian virtualenv build keeps shipping
`systemd-python>=231` in the venv, so the packaged log config can keep
using `systemd.journal.JournalHandler`

Context of this is the following:

> Today in my 'how hard would it be to move to uv' journey:
https://github.com/systemd/python-systemd/issues/167
>
> The gist of it is that uv really wants to create a universal lock
file, which means it needs to be able to resolve the package metadata,
even for packages locked for other platforms. In the case of
systemd-python, they use mesonpy as build backend, which doesn't
implement prepare_metadata_for_build_wheel, which means it needs to run
meson to be able to resolve the package metadata. And it will hard-fail
if libsystemd dev headers aren't available 😭
>
> [*message in
#synapse-dev:matrix.org*](https://matrix.to/#/!i5D5LLct_DYG-4hQprLzrxdbZ580U9UB6AEgFnk6rZQ/$OKLB3TJVXAwq43sAZFJ-_PvMMzl4P_lWmSAtlmsoMuM?via=element.io&via=matrix.org&via=beeper.com)
2026-03-09 15:11:04 +00:00
Travis Ralston
6e21f9c12b Add unstable federation API for MSC4370 GET /extremities (#19314)
MSC (recommended reading):
https://github.com/matrix-org/matrix-spec-proposals/pull/4370

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: turt2live <1190097+turt2live@users.noreply.github.com>
Co-authored-by: Olivier 'reivilibre' <oliverw@element.io>
2026-03-05 18:30:52 +00:00
Mathieu Velten
699a898b30 Backgrounds membership updates when changing the avatar or the display name (#19311) 2026-03-05 14:46:05 +00:00
Eric Eastwood
46c6e0ae1e Unify Complement developer docs (#19518)
Instead of having info spread across a few places, consolidate and link
to one spot.
2026-03-03 13:18:49 -06:00
Quentin Gliech
fd61b8eeb0 Merge branch 'release-v1.149' into develop 2026-03-03 17:24:12 +01:00
Eric Eastwood
51048b8e36 Update docs to clarify outbound_federation_restricted_to can also be used with the SBG (#19517)
[Secure Border Gateway (SBG)](https://element.io/en/server-suite/secure-border-gateways)

Spawning from [internal
discussion](https://matrix.to/#/!mNoPShRlwEeyHAEJOe:element.io/$6eGip85OUKOmyK1VzqrFMc7eF7dON7Vs76O40kVbRRY?via=banzan.uk&via=element.io&via=jki.re)
around integrating [Synapse Pro for small
hosts](https://docs.element.io/latest/element-server-suite-pro/synapse-pro-for-small-hosts/overview)
in the [Element Server Suite (ESS)](https://element.io/en/server-suite)
stack and wanting it be compatible with the SBG.

We know that the SBG works with monolith Synapse because that's what we
have configured with the [Complement tests in the SBG
repo](b76b05b53e/complement/configure_synapse_for_sbg.sh (L8-L10)).
2026-03-03 10:04:37 -06:00
Quentin Gliech
639922e835 1.149.0rc1 2026-03-03 15:38:17 +01:00
Eric Eastwood
160d9788c0 Simplify Rust HTTP client response streaming and limiting (#19510)
*As suggested by @sandhose in
https://github.com/element-hq/synapse/pull/19498#discussion_r2865607737,*

Simplify Rust HTTP client response streaming and limiting


### Dev notes

Synapse's Rust HTTP client was introduced in
https://github.com/element-hq/synapse/pull/18357



### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
2026-03-03 15:24:25 +01:00
Eric Eastwood
c3af44339c Fix /sync missing membership in state_after (re-introduce) (#19460)
*This PR was originally only to enable
[MSC4222](https://github.com/matrix-org/matrix-spec-proposals/pull/4222)
Complement tests (`/sync` `state_after`) but after merging the [fix
PR](https://github.com/element-hq/synapse/pull/19463), we discovered
that while the tests pass locally, [fail in
CI](https://github.com/element-hq/synapse/pull/19460#discussion_r2818080879).
To unblock the RC, we decided to revert the fix PR (see
https://github.com/element-hq/synapse/pull/19474#discussion_r2818061001
for more info). To better ensure tests actually pass in CI, we're
re-introducing the fix here in the same PR that we enable the tests in.*

---

Fix `/sync` missing membership in `state_after`.

This applies to any scenario where the first membership has a different
`sender` compared to the `state_key` and then the second membership has
the same `sender`/`state_key`. Like someone inviting another person and
then them joining. Or someone being kicked and then they leave.

This bug has been present since the MSC4222 implementation was
introduced into the codebase
(https://github.com/element-hq/synapse/pull/17888).

---

Fix https://github.com/element-hq/synapse/issues/19455
Fix https://github.com/element-hq/customer-success/issues/656

I have a feeling, this might also fix these issues (will close and see
how people report back):

Fix https://github.com/element-hq/synapse/issues/18182
Fix https://github.com/element-hq/synapse/issues/19478

 ### Testing strategy

Complement tests: https://github.com/matrix-org/complement/pull/842

We will need https://github.com/element-hq/synapse/pull/19460 to merge
in order to enable the Complement tests in Synapse but this PR should be
merged first so they pass in the first place. I've tested locally that
the Complement tests pass with this fix.




### Dev notes


[MSC4222](https://github.com/matrix-org/matrix-spec-proposals/pull/4222)
has already been merged into the spec and is already part of Matrix
v1.16 but we haven't [stabilized support in Synapse
yet](https://github.com/element-hq/synapse/issues/19414).

---

In the same ballpark:

 - https://github.com/element-hq/synapse/issues/19455
 - https://github.com/element-hq/synapse/issues/17050
 - https://github.com/element-hq/synapse/issues/17430
 - https://github.com/element-hq/synapse/issues/16940
 - https://github.com/element-hq/synapse/issues/18182
 - https://github.com/element-hq/synapse/issues/18793
 - https://github.com/element-hq/synapse/issues/19478

---

Docker builds preferring remote image over the local image we just
built,
https://github.com/element-hq/synapse/pull/19460#discussion_r2818080879

`containerd` image store (storage driver, driver type)

-> https://github.com/element-hq/synapse/pull/19475


### Todo

- [x] Wait for https://github.com/element-hq/synapse/pull/19463 to merge
so the Complement tests all pass
- [x] Wait for https://github.com/element-hq/synapse/pull/19475 to merge

### Pull Request Checklist

<!-- Please read
https://element-hq.github.io/synapse/latest/development/contributing_guide.html
before submitting your pull request -->

* [x] Pull request is based on the develop branch
* [x] Pull request includes a [changelog
file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog).
The entry should:
- Be a short description of your change which makes sense to users.
"Fixed a bug that prevented receiving messages from other servers."
instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
  - Use markdown where necessary, mostly for `code blocks`.
  - End with either a period (.) or an exclamation mark (!).
  - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by
@github_username." or "Contributed by [Your Name]." to the end of the
entry.
* [x] [Code
style](https://element-hq.github.io/synapse/latest/code_style.html) is
correct (run the
[linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))

---------

Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
2026-03-03 15:13:59 +01:00
Quentin Gliech
094a48efb5 Bump all locked dependencies to their latest versions. (#19519)
This is a manual lock bump, as it looks like Dependabot is currently
timing out updating dependencies. This should hopefully unlock it, as it
will have fewer dependencies to update.

Two outstanding exceptions:

- pympler upgrade adds a pywin32 deps, which is missing sdist (so CI is
complaining)
- pysaml2 for some unknown reason pinned the MAX version of pyopenssl,
which duplicates pyopenssl and cryptography, which obviously breaks
stuff
2026-03-03 14:29:59 +01:00
Olivier 'reivilibre
825f3087bf Replace deprecated collection import locations with current locations. (#19515)
Use non-deprecated imports for collections

Other than being deprecated, these legacy imports also don't seem to be
compatible with [Ty](https://github.com/astral-sh/ty)

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-03-02 18:15:33 +00:00
Erik Johnston
0d3e42f21f Yield to reactor in large loops (#19507)
When a worker gets very busy some of these loops can get large and end
up taking hundreds of ms to complete. To help keep the reactor tick
times reasonable we add a periodic yield into these loops.

These were found by doing a `py-spy` and speedscope.net (in time order)
to see where we were spending blocks of time
2026-03-02 09:36:27 +00:00
Eric Eastwood
979566ed8f Pre-allocate the buffer based on the expected Content-Length with the Rust HTTP client (#19498)
Spawning from
[looking](https://matrix.to/#/!cnVVNLKqgUzNTOFQkz:matrix.org/$XOVFm5mjCzzmhUaGc202zGdSq8eWgjr00MJqNSfzHiA?via=element.io&via=matrix.org&via=one.ems.host)
at some traces and seeing the Synapse Rust HTTP client taking way longer
than what the Synapse Pro Event Cache claims it was able to respond in
(added some [better
tracing](https://github.com/element-hq/synapse-pro-modules/pull/38) for
that). I don't think this specific change will have a meaningful impact
but just something I saw (pre-optimization).
2026-02-27 16:25:26 -06:00
Richard van der Hoff
b9ea2285b3 Add stable support for MSC4380 invite blocking. (#19431)
MSC4380 has now completed FCP, so we can add stable support for it.

Co-authored-by: Quentin Gliech <quenting@element.io>
2026-02-27 14:47:07 +00:00
Erik Johnston
2c73e8daef Allow long lived syncs to be cancelled if client has gone away (#19499) 2026-02-26 21:41:06 +00:00
Hugh Nimmo-Smith
f78d011df1 Experimental implementation of unstable MSC4388 for Sign in with QR (#19127)
Co-authored-by: Olivier 'reivilibre' <oliverw@element.io>
2026-02-25 17:41:51 +00:00
Eric Eastwood
ac3a115511 Log if we ever gc.freeze() (#19440)
Spawning from
https://github.com/element-hq/synapse-small-hosts/issues/348 where some
test appears to be flaky because some homeserver objects are frozen in
the garbage collector.

We set
[`freeze=False`](a9a6869aa9/multi_synapse/app/shard.py (L319-L321))
in the [Synapse Pro for small
hosts](https://docs.element.io/latest/element-server-suite-pro/synapse-pro-for-small-hosts/overview/)
code but I just want to use this log to make extra sure this isn't being
run somehow. The follow-up here would be to see what else would cause
something to be frozen in the garbage collector.
2026-02-25 09:47:13 -06:00
Brad Murray
bc15ed3c62 DeviceHandler: Add a log line when we delete a device (#19496)
Deleting devices should be fairly
rare, and if someone gets logged out it's helpful to grep logs for a
user id or device id and see where it died.
2026-02-24 14:18:52 -06:00
Olivier 'reivilibre
16245f0550 Fix the 'Login as a user' Admin API not checking if the user exists before issuing an access token. (#18518)
Fixes: #18503

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
Co-authored-by: Quentin Gliech <quenting@element.io>
2026-02-20 15:52:29 +00:00
Olivier 'reivilibre
4500652459 Rename the test_disconnect test helper so that pytest doesn't see it as a test. (#19486)
This fixes one of the 2 blockers to using pytest instead of Trial (which
is not formally-motivated, but sometimes seems like an interesting idea
because
pytest has seen a lot of developer experience features that Trial
hasn't. It would also removes one more coupling to the Twisted
framework.)

---

The `test_` prefix to this test helper makes it appear as a test to
pytest.

We *can* set a `__test__ = False` attribute on the test, but it felt
cleaner to just rename it (as I also thought it would be a test from
that name!).

This was previously reported as:
https://github.com/element-hq/synapse/issues/18665

---------

Signed-off-by: Olivier 'reivilibre <oliverw@matrix.org>
2026-02-20 15:37:34 +00:00
Eric Eastwood
04206aebdf Log docker system info in CI (#19480)
Follow-up to
https://github.com/element-hq/synapse/pull/19460#discussion_r2819139638
and https://github.com/element-hq/synapse/pull/19475
2026-02-19 09:57:25 -06:00