While trying to update my display name, I've realized that any display name longer than 20 characters gets rejected (specifically: https://lemmy.ml/api/v3/user/save_user_settings returns 400 with {"error":"invalid_display_name"}). Some digging through the code seems to explain why: Lemmy 0.19.20 (the version running on lemmy.ml) uses the same config option for limiting display name length as it does for usernames, which defaults to 20 (and .ml hasn't changed it from the default value)¹.
I would be satisfied with that explanation, except there are clearly other users on my instance whose display names exceed 20 characters (example: https://lemmy.ml/u/Trying2KnowMyself). So, my question is: how the heck are people able to set these longer display names?
¹ In the 1.0 betas the config option seems to have been replaced with hardcoded limits which are separate for user- and display names, but I don't think that'd be relevant since that's not the code which .ml is actually running
EDIT: I figured it out! Importing user settings from a json backup bypasses display name validation. Most likely the user I referenced as an example had imported their profile from their Hexbear alt, so it ended up just copying their display name over as well.
trying2knowmyself has 17 characters.
Their username is Trying2KnowMyself, but their display name is "Trying2KnowMyself [they/them/their/theirs/themself]" which is significantly more than 17 characters
If I remember correctly, all the extraneous stuff in brackets is just flair that you can set to whatever. It has nothing to do with your username.
I know, and I am not trying to change my username. The display name is an arbitrary string which, if set, is shown in place of the username. Many users have their display name formatted like " []", but it doesn't have to be related to the username at all - I could set my display name to "aaaaaaaaaaa" or "ಠ_ಠ" if I wanted to.
I also wasn't asking how to set a display name, I know how to do that. My question was how people set their display name to be longer than 20 characters, since although that is the limit of what Lemmy allows, some users have display names exceeding the limit.
Anyway, the question isn't an issue anymore, since I figured out how the user in question managed to circumvent the limit.