Skip to content

GET /_matrix/client/v3/devices is returning null for display_name (not spec compliant) #376

@Giwayume

Description

@Giwayume

https://spec.matrix.org/v1.17/client-server-api/#get_matrixclientv3devices_response-200_device

Image

Fields not listed as required in the spec generally must be absent from the response when they are optional. In this case if a display_name is not set, it should be missing from the JSON, instead of being returned as a null value.

Incorrect

{
    "device_id": "ABCDEF123",
    "display_name": null,
    "last_seen_ip": "127.0.0.1",
    "last_seen_ts": 0
},

Correct

{
    "device_id": "ABCDEF123",
    "last_seen_ip": "127.0.0.1",
    "last_seen_ts": 0
},

Wherever null is an allowed value, it is explicitly defined as part of the type, such as in this example.

Image

Yeah the spec is a bit problematic

If following the spec, there is no documented way to remove a device name after it is set. Clients must effectively treat undefined (never set) and empty string as "no display name". During an update, omitting display_name results in no change.

Image

Suggestion for compatibility

Start omitting display_name from the GET /_matrix/client/v3/devices response where it is currently null today, but still accept null in the PUT /_matrix/client/v3/devices/{deviceId} request for clients that may be relying on using null to unset the display_name in a non-compliant way.

E.g. if a client sends null for display_name, translate this to omitting display_name when GET /_matrix/client/v3/devices is called.

Metadata

Metadata

Assignees

Labels

bugSomething isn't right.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions