Skip to content

Return an M_NOT_FOUND error body for unknown events on federation /event - #20546

Open
WPTK wants to merge 2 commits into
element-hq:developfrom
WPTK:fix-federation-event-404
Open

WPTK wants to merge 2 commits into
element-hq:developfrom
WPTK:fix-federation-event-404

Conversation

@WPTK

@WPTK WPTK commented Nov 21, 2026

Copy link
Copy Markdown

Fixes #3648.

When a remote server asked for an event we don't have over federation (GET /_matrix/federation/v1/event/<event_id>), Synapse responded with a 404 and an empty-string body. The spec requires a standard Matrix error object. This now raises NotFoundError, so the response is {"errcode": "M_NOT_FOUND", "error": "Event not found"}.

Also corrects the return type annotation of on_pdu_request and FederationEventServlet.on_GET (no longer JsonDict | str).

Added test_get_event_unknown_event_returns_not_found in tests/federation/test_federation_server.py.

Checked: trial tests.federation (186 passed, 2 skipped), ruff check, ruff format --check and mypy synapse/federation all clean, run on Linux against this branch. Not run: Postgres variants, complement.

AI disclosure: this change was written with the help of Claude (Anthropic) on behalf of the submitter, who is responsible for it. The tests and linters above were actually run.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file (added right after opening, once the PR number was known)
  • Code style is correct (ruff check / ruff format --check pass)

@WPTK
WPTK requested a review from a team as a code owner November 21, 2026 17:41
@WPTK
WPTK requested review from sandhose and removed request for a team November 21, 2026 17:41
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Federation A-Spec-Compliance Matrix spec compliance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Synapse returns an empty string instead of an M_NOT_FOUND when requesting an event that doesn't exist/is hidden

4 participants