Repository navigation
Return 200 {} again for an unset displayname/avatar_url - #20200
Conversation
Since #18635, `GET /profile/{userId}/{displayname,avatar_url}` returns `{"<field>": null}` when the field is unset, rather than the empty object it returned before. Add a test asserting the previous behaviour. Claude-Session: https://claude.ai/code/session_012TjugsZmHDB6Rx4pqa4hA9
`GET /profile/{userId}/{displayname,avatar_url}` returned
`{"<field>": null}` for an unset field since #18635 unified the
displayname, avatar_url and custom field servlets. Restore the previous
behaviour of returning an empty object when the field is unset.
Custom fields are unaffected: those already return a 404 when unset.
Claude-Session: https://claude.ai/code/session_012TjugsZmHDB6Rx4pqa4hA9
| ret[field_name] = await self.profile_handler.get_profile_field( | ||
| user, field_name | ||
| ) |
There was a problem hiding this comment.
Should the generic profile field case also have the same fix applied?
There was a problem hiding this comment.
I think for now, the ecosystem, is going to accept a bit of inconsistencies with HomeServers either returning 200 {} or 404.
Here get_profile_field would raise StoreError(404, "No row found") and the HS would return 404.
I'm open to also making it return 200 {} for consistency, but the spec might change in the future back to 404 for all fields, because that is probably the correct REST semantic response
The next final change I would like to make on this matter is rather changing definitely to 404 for all fields once the spec settles and clients all accepts 404 as response for unset fields.
There was a problem hiding this comment.
Fair enough. I agree with your assessment.
It's probably worth adding a comment in with this information so future developers don't have to go digging for why the different cases treat response handling in different ways.
|
Other than the one question, the changes here look complete to me. |
|
👋 thanks for your review, I replied to your question |
Part of: #19414
When MSC4133 (custom profile fields) was implemented, the returned value for an unset display name changed from
200 {}to200 { displayname: null }. This happened first on the unstableuk.tcpip.msc4133path in #17488 (1.123.0), then on the stable path when #18635 (1.135.0) unified thedisplayname,avatar_urland custom field servlets. Neither PR discussed the change in review, so it looks like an unintended side effect of the refactor rather than a deliberate decision.The v1.16 spec mandated to change from returning
200 {}to404but change was not identified as breaking and was eventually not implemented in other clients and server. This PR has a sister MSC that proposes to return to the pre-1.16 error codes: MSC4537.Before:
After:
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.