From 796877a5944618fbebb8e8bbfe9fa8390fd4d425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 3 Apr 2026 15:11:50 +0200 Subject: [PATCH] Fix ranked play test failures from adding null playlist items (#37189) Example: https://github.com/ppy/osu/actions/runs/23900675414/job/69696255970?pr=37178#step:5:38 Regressed in https://github.com/ppy/osu/pull/37172, cc @LiquidPL Would fail in multiple tests. I'm not going to spend time figuring out exactly why, I'm just going to guess that not all tests bother to set up the relevant playlist items for the cards or whatever. Some of the failing tests are flaky but not because the `item` here isn't sometimes null in those cases. It's always null, but the callbacks are probably scheduled or whatever and therefore have a chance to never run. Also some of the failures appear to cascade / spill from other tests as well. --- .../Visual/Multiplayer/TestMultiplayerClient.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs index a5116cf2dd..2f11ab94b3 100644 --- a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs +++ b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs @@ -860,15 +860,18 @@ namespace osu.Game.Tests.Visual.Multiplayer public async Task PlayUserCard(int userId, Func selector) { RankedPlayCardItem card = selector(((RankedPlayRoomState)ServerRoom!.MatchState!).Users[userId].Hand.ToArray()); - MultiplayerPlaylistItem item = GetCardWithPlaylistItem(card).PlaylistItem.Value!; + MultiplayerPlaylistItem? item = GetCardWithPlaylistItem(card).PlaylistItem.Value; - ServerRoom!.Playlist.Add(item); - await ((IMultiplayerClient)this).PlaylistItemAdded(clone(item)).ConfigureAwait(false); - await ((IMultiplayerClient)this).PlaylistItemChanged(clone(item)).ConfigureAwait(false); + if (item != null) + { + ServerRoom!.Playlist.Add(item); + await ((IMultiplayerClient)this).PlaylistItemAdded(clone(item)).ConfigureAwait(false); + await ((IMultiplayerClient)this).PlaylistItemChanged(clone(item)).ConfigureAwait(false); - var settings = clone(ServerRoom!.Settings); - settings.PlaylistItemId = item.ID; - await ((IMultiplayerClient)this).SettingsChanged(settings).ConfigureAwait(false); + var settings = clone(ServerRoom!.Settings); + settings.PlaylistItemId = item.ID; + await ((IMultiplayerClient)this).SettingsChanged(settings).ConfigureAwait(false); + } await ((IRankedPlayClient)this).RankedPlayCardPlayed(clone(card)).ConfigureAwait(false); }