synapse/synapse
Devon Hudson 119f02e3b3
Return 400 when canonical_alias content invalid (#19240)
Fixes #19198

Returns HTTP 400 when `alias` or `alt_alias` inside of
`m.room.canonical_alias` `content` are not of type string.
Previously this resulted in HTTP 500 errors as Synapse assumed they were
strings and would raise an exception when it tried to treat them as such
if they actually weren't.

With the changes implemented:
<img width="800" height="616" alt="Screenshot from 2025-11-28 16-48-06"
src="https://github.com/user-attachments/assets/1333a4b3-7b4f-435f-bbff-f48870bc4d96"
/>
<img width="800" height="316" alt="Screenshot from 2025-11-28 16-47-42"
src="https://github.com/user-attachments/assets/5928abf8-88a2-4bd9-9420-9a1f743f66f5"
/>

### 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))
2025-12-01 15:24:26 +00:00
..
_scripts MSC4140: Remove auth from delayed event management endpoints (#19152) 2025-11-13 18:56:17 +00:00
api Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
app Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
appservice Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
config Implement MSC4380: Invite blocking (#19203) 2025-11-26 16:12:14 +00:00
crypto Write union types as X | Y where possible (#19111) 2025-11-06 14:02:33 -06:00
events Write union types as X | Y where possible (#19111) 2025-11-06 14:02:33 -06:00
federation Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
handlers Return 400 when canonical_alias content invalid (#19240) 2025-12-01 15:24:26 +00:00
http Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
logging Restore printing sentinel for log_record.request (#19172) 2025-11-13 09:57:56 -06:00
media Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
metrics Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
module_api Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
push Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
replication Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
res Updated providers.json to use X instead of Twitter following rebrand and schema change (#18767) 2025-09-26 11:06:50 +01:00
rest Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
server_notices Write union types as X | Y where possible (#19111) 2025-11-06 14:02:33 -06:00
spam_checker_api Correctly mention previous copyright (#16820) 2024-01-23 11:26:48 +00:00
state Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
static Update link to the clients webpage, fix #15825 (#15874) 2023-07-06 17:28:09 +02:00
storage Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
streams Write union types as X | Y where possible (#19111) 2025-11-06 14:02:33 -06:00
synapse_rust Write union types as X | Y where possible (#19111) 2025-11-06 14:02:33 -06:00
types Expire sliding sync connections (#19211) 2025-11-25 10:20:47 +00:00
util Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
__init__.py Drop Python 3.9, bump tests/builds to Python 3.10 (#19099) 2025-10-29 12:15:00 -05:00
event_auth.py Write union types as X | Y where possible (#19111) 2025-11-06 14:02:33 -06:00
notifier.py Port Clock functions to use Duration class (#19229) 2025-12-01 13:55:06 +00:00
py.typed
server.py Write union types as X | Y where possible (#19111) 2025-11-06 14:02:33 -06:00
visibility.py Move call invite filtering logic to filter_events_for_client (#17782) 2025-11-28 17:41:56 +00:00