Skip to content

Conversation

@EYHN
Copy link
Contributor

@EYHN EYHN commented Jul 12, 2025

I found that the current version cannot open the beatmap detail created by a deleted account.

This bug is introduced by #33783 .

The reason is that user.id in the JSON returned by osu-web is null, which causes the APIUser fail to deserialize.

Screenshot 2025-07-12 213518

Because the Id of APIUser is int, it cannot be null.
I don't want to change Id to int?, so in this PR i added NullValueHandling.Ignore to it. This way, null values will be ignored during deserialize, and Id will still retain its default value (i.e. 1)

@EYHN EYHN marked this pull request as ready for review July 12, 2025 14:40
@EYHN EYHN changed the title Fix failed to load beatmaps host by deleted user Fix failed to load beatmap detail host by deleted user Jul 12, 2025
@smoogipoo
Copy link
Contributor

Can you link a relevant beatmap? And also add a test case for this in TestSceneBeatmapSetOverlay, even if it's just deserialising a raw JSON string?

@EYHN
Copy link
Contributor Author

EYHN commented Jul 14, 2025

Can you link a relevant beatmap?

https://osu.ppy.sh/beatmapsets/25

And also add a test case for this in TestSceneBeatmapSetOverlay, even if it's just deserialising a raw JSON string?

I didn't find any other test cases for deserialising raw JSON that I could refer to. It's a pretty complex json and I'm not sure if I should be doing this.

Maybe we should have a deserialization test? Because this time the issue is in from Deserializer.

The original response:

APIBeatmapSet.json

@smoogipoo
Copy link
Contributor

smoogipoo commented Jul 14, 2025

The part I was interested in a test for was for how it actually displays with a user-id of 1.

I was thinking you could do something like this:

[Test]
public void TestDeletedUser()
{
    AddStep("show map with deleted user", () =>
    {
        JObject jsonBlob = JObject.FromObject(getBeatmapSet(), new JsonSerializer
        {
            ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        });

        jsonBlob["user"] = JToken.Parse(
            """
            {
                "id": null,
                "username": "[deleted user]"
            }
            """);

        overlay.ShowBeatmapSet(JsonConvert.DeserializeObject<APIBeatmapSet>(JsonConvert.SerializeObject(jsonBlob)));
    });
}

Though you'll have to set a few more properties - perhaps jsonBlob.Remove("user_id") and others. That's why I wanted the raw JSON to reference.

@EYHN
Copy link
Contributor Author

EYHN commented Jul 14, 2025

I have added a test, and I adjusted the author field in APIBeatmapSet.

Now the BeatmapSet detail will shows the username of the deleted account, which is consistent with the web.

Before new commit
Screenshot (23)

After
Screenshot (22)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants