element-hq / element-hq/synapse

Unable to login with long initial_device_display_name

Open
#18,249 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

Login via the `_matrix/client/v3/login` endpoint fails when providing an `initial_device_display_name` exceeding 100 characters. The character limit is *not* an explicit restriction listed in the [relevant part of the Matrix spec](https://spec.matrix.org/v1.13/client-server-api/#post_matrixclientv3login).

I ran into this problem while logging in from Element Web to a domain with a rather long DNS name. I feel that instead of fixing this client-side in Element Web, a graceful handling on the server would be more appropriate. This handling could, e.g., consist of truncating the submitted string.

### Function emitting the error

https://github.com/element-hq/synapse/blob/d61bdff7a445e6c9d345c23917ba920eb737717d/synapse/handlers/device.py#L567-L583

### Reproducer

```console
$ curl \
-d "{ \
\"type\": \"m.login.password\", \
\"identifier\": { \
\"type\": \"m.id.user\", \
\"user\": \"username\" \
}, \
\"password\": \"password\", \
\"initial_device_display_name\": \
\"A very long and problematic initial device display name that exceeds the maximum character limit of 100 characters\" \
}" \
https://matrix.example.org/_matrix/client/v3/login
{"errcode":"M_TOO_LARGE","error":"Device display name is too long (max 100)"}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.