osu-web icon indicating copy to clipboard operation
osu-web copied to clipboard

If user was deleted, some fields of User are null unlike the docs

Open ilsubyeega opened this issue 2 years ago • 5 comments

Docs: https://osu.ppy.sh/docs/index.html#usercompact Url: /api/v2/beatmapsets/4

// .....
  "user": {
    "avatar_url": null, // <-- This is not nullable from docs
    "country_code": null, // <-- This is not nullable from docs
    "default_group": "default",
    "id": null, // <-- This is not nullable from docs
    "is_active": false,
    "is_bot": false,
    "is_deleted": true,
    "is_online": false,
    "is_supporter": false,
    "last_visit": null,
    "pm_friends_only": false,
    "profile_colour": null,
    "username": "[deleted user]"
  }
// ....

ilsubyeega avatar Sep 09 '23 02:09 ilsubyeega

I guess we omit these fields rather than listing as null? Or just provide a null user instead?

peppy avatar Sep 12 '23 08:09 peppy

They should probably default to the same values as https://github.com/ppy/osu-web/blob/master/resources/js/models/user.ts

Then again, the js side has defaults to make typing assumptions simpler 🤔

notbakaneko avatar Sep 13 '23 03:09 notbakaneko

Created a small wrapper around the osu! API for a project and am just now discovering this quirk. Going to have to rewrite a lot of parsing logic considering UserCompact is such a widely used object. At the very least, It would be nice if the docs were updated to indicate which fields here are nullable.

I guess we omit these fields rather than listing as null? Or just provide a null user instead?

I think returning a null user is a much better approach

myssto avatar Jan 26 '25 03:01 myssto

I'm also fine with null user FWIW, it sounds more correct.

peppy avatar Jan 28 '25 00:01 peppy

There are a few places where there's only user object and the user id is still kind of relevant even though the user is deleted (~the most recent one being beatmap owners~ or maybe not, that one isn't user object at all).

nanaya avatar Jan 28 '25 08:01 nanaya