Skip to content

Fix GET /_matrix/federation/v1/user/devices/{userId} response #18739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

SnackEngineer
Copy link
Contributor

@SnackEngineer SnackEngineer commented Jul 28, 2025

Don't send the fields master_key and self_signing_key when they are not defined for the queried user device.'

Before this change they would be sent and set to null in the JSON response object, which would violate the OpenAPI definitions (https://spec.matrix.org/v1.3/server-server-api/#get_matrixfederationv1userdevicesuserid).

12

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. 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.
  • Code style is correct (run the linters)

@SnackEngineer SnackEngineer requested a review from a team as a code owner July 28, 2025 10:20
Comment on lines +870 to +873
# do not set the master_key field if it is None,
# since then we send a null in the JSON response
if master_key is not None:
json_body["master_key"] = master_key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this change they would be sent and set to null in the JSON response object, which would violate the OpenAPI definitions (https://spec.matrix.org/v1.3/server-server-api/#get_matrixfederationv1userdevicesuserid).

According to the spec, master_key and self_signing_key are not required fields.

The OpenAPI spec for the /user/devices/{userId} endpoint is here: https://github.com/matrix-org/matrix-spec/blob/7d2de48cb4774db60c63bc339daf089dd09387cd/data/api/server-server/user_devices.yaml#L20-L108

Where does the OpenAPI spec say that null isn't valid for an optional field?

What prior art in the Matrix spec are you leaning on that it's better to omit the fields?

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.

2 participants