Skip to content

Require the 'to' parameter on /keys/changes - #20547

Open
WPTK wants to merge 3 commits into
element-hq:developfrom
WPTK:keys-changes-require-to
Open

WPTK wants to merge 3 commits into
element-hq:developfrom
WPTK:keys-changes-require-to

Conversation

@WPTK

@WPTK WPTK commented Nov 21, 2026

Copy link
Copy Markdown

Fixes #3058.

The Matrix spec marks the to query parameter of GET /_matrix/client/v3/keys/changes as required, but Synapse accepted requests without it (a long-standing XXX comment in the code noted this). It is now required, so a request without to gets a 400 M_MISSING_PARAM. As before, the value is otherwise ignored.

Behaviour change to be aware of: a client that omitted to previously succeeded and will now get a 400. The spec already requires the parameter, but maintainers may want to weigh whether that is acceptable.

Added test_missing_to_param in tests/rest/client/test_keys.py.

Checked: trial tests.rest.client.test_keys (11 passed), ruff check, ruff format --check and mypy on the touched files, 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 barodeur 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.

@barodeur barodeur 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.

I'm not sure that this really adds much value to Synapse.

The ?to parameter has been ignored voluntarily since the initial implementation matrix-org/synapse#13345.

Comment thread changelog.d/20546.bugfix

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.

⚠️ this file belong in #20546

Comment on lines -386 to +388
# We want to enforce they do pass us one, but we ignore it and return
# changes after the "to" as well as before.
#
# XXX This does not enforce that "to" is passed.
set_tag("to", str(parse_string(request, "to")))
# The spec requires `to` to be passed. We enforce that, but otherwise
# ignore it and return changes after the "to" as well as before.
set_tag("to", parse_string(request, "to", required=True))

@barodeur barodeur Nov 23, 2026 •

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.

As per @MadLittleMods suggestion, I'm making sure my review comment is discussable a github discussion:

I'm not sure that this really adds much value to Synapse.

The ?to parameter has been ignored voluntarily since the initial implementation matrix-org/synapse#13345.

— #20547 (review)

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow the spec regarding /client/r0/keys/changes

4 participants