If user was deleted, some fields of User are null unlike the docs
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]"
}
// ....
I guess we omit these fields rather than listing as null? Or just provide a null user instead?
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 🤔
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
I'm also fine with null user FWIW, it sounds more correct.
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).