If a user doesn't have a username "set" for an account, then the display_name field is omitted.
This is similar to a few other questions, but the only official answer says that "display_name should always be set now". Is this a bug, or is this something we are expected to watch for?
I will suggest that it is a bug. Consider my associated accounts JSON - I don't have a display_name for meta.stackoverflow.com, for some reason.
"user_id": 3788,
"user_type": "registered",
"reputation": 934,
"on_site": {
"name": "Meta Stack Overflow",
When I go to meta, it shows my name as user3788
. I realize that this isn't my official display name, and that it won't work with "mentions", but it is also the, uh, /name/ that is /displayed/ (see what I did there? :) for me around the site.
In that sense, there is no obvious functional distinction between user3788
and a proper display name. Because it is most often used as the thing that I look at.
I suggest, then, that the display_name field show exactly what shows up when I use the website - which, in this case, is that temporary identifier.
Additionally, the JSON help page for "associated accounts" lists diaplay_name as a "required" field. So either that field should always be set (to some default value - whatever you decide) or it should be known that it may not exist and that we are expected to check for that condition.
Whatever you all choose to do is totally okay - though I have my own preference for the API's behavior. But I just wanted to ask this, despite other duplicate questions, to ask for clarity on the matter! This is serious business!