From 2d177226fdc14974a9520eecc7c8198247a62ee8 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 29 Oct 2025 15:08:32 +0900 Subject: [PATCH 1/2] Add failing test --- .../TestSceneBeatmapSelectPanel.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/osu.Game.Tests/Visual/Matchmaking/TestSceneBeatmapSelectPanel.cs b/osu.Game.Tests/Visual/Matchmaking/TestSceneBeatmapSelectPanel.cs index 02c669aaf5..01f76157f1 100644 --- a/osu.Game.Tests/Visual/Matchmaking/TestSceneBeatmapSelectPanel.cs +++ b/osu.Game.Tests/Visual/Matchmaking/TestSceneBeatmapSelectPanel.cs @@ -1,11 +1,13 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using System; using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Graphics.Cursor; using osu.Game.Online.API; +using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.Rooms; using osu.Game.Overlays; @@ -62,5 +64,41 @@ namespace osu.Game.Tests.Visual.Matchmaking panel.AllowSelection = value; }); } + + [Test] + public void TestFailedBeatmapLookup() + { + AddStep("setup request handle", () => + { + var api = (DummyAPIAccess)API; + var handler = api.HandleRequest; + api.HandleRequest = req => + { + switch (req) + { + case GetBeatmapRequest: + case GetBeatmapsRequest: + req.TriggerFailure(new InvalidOperationException()); + return false; + + default: + return handler?.Invoke(req) ?? false; + } + }; + }); + + AddStep("add panel", () => + { + Child = new OsuContextMenuContainer + { + RelativeSizeAxes = Axes.Both, + Child = new BeatmapSelectPanel(new MultiplayerPlaylistItem()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + } + }; + }); + } } } From e9260de56fcda11d4111757851e7ebc714a86022 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 29 Oct 2025 15:15:36 +0900 Subject: [PATCH 2/2] Fix potential nullref if beatmap lookup fails --- .../Match/BeatmapSelect/BeatmapSelectPanel.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/Match/BeatmapSelect/BeatmapSelectPanel.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/Match/BeatmapSelect/BeatmapSelectPanel.cs index 001804a521..aa0329ad94 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/Match/BeatmapSelect/BeatmapSelectPanel.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/Match/BeatmapSelect/BeatmapSelectPanel.cs @@ -111,7 +111,17 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Match.BeatmapSelect { Debug.Assert(card == null); - var beatmap = b.GetResultSafely()!; + APIBeatmap beatmap = b.GetResultSafely() ?? new APIBeatmap + { + BeatmapSet = new APIBeatmapSet + { + Title = "unknown beatmap", + TitleUnicode = "unknown beatmap", + Artist = "unknown artist", + ArtistUnicode = "unknown artist", + } + }; + beatmap.StarRating = Item.StarRating; mainContent.Add(card = new BeatmapCardMatchmaking(beatmap)