Return 403 instead of 400 when profile changes are disabled - #20173
Merged
erikjohnston merged 3 commits intoSep 2, 2026
Merged
Conversation
With enable_set_displayname: false / enable_set_avatar_url: false, the spec requires PUT/DELETE on the corresponding profile field to be refused with HTTP 403 M_FORBIDDEN, not 400. Assert the status code in the existing handler tests and add REST-level coverage for PUT and DELETE on displayname and avatar_url.
The spec defines the 403 response of
PUT|DELETE /_matrix/client/v3/profile/{userId}/{keyName} as "The server
is unwilling to perform the operation, either due to insufficient
permissions or because profile modifications are disabled", while 400
is reserved for malformed input. Synapse raised these refusals with
HTTP 400 and errcode M_FORBIDDEN; use 403 to match the errcode and the
spec, consistent with the other profile refusals (disallowed avatars,
custom profile fields).
erikjohnston
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
enable_set_displayname: false(orenable_set_avatar_url: false), refusing a profile change returned the right errcode with the wrong status:With this fix:
The spec defines the 403 response of
PUT /_matrix/client/v3/profile/{userId}/{keyName}as "The server is unwilling to perform the operation, either due to insufficient permissions or because profile modifications are disabled", while 400 is reserved for malformed input (M_BAD_JSON,M_MISSING_PARAM, …).Clients seem to rely on
errcodefield more than the HTTP Status Code, that change seems safe.Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.