{"record":{"id":"6e6c7e4b16ab7441","repo":"ppy/osu","slug":"item-does-not-exist-in-the-room","errorCode":null,"errorMessage":"Item does not exist in the room.","messagePattern":"Item does not exist in the room\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs","lineNumber":593,"sourceCode":"            item.PlaylistOrder = existingItem.PlaylistOrder;\r\n\r\n            ServerRoom.Playlist[ServerRoom.Playlist.IndexOf(existingItem)] = item;\r\n            ServerAPIRoom.Playlist = ServerAPIRoom.Playlist.Select((pi, i) => pi.ID == item.ID ? new PlaylistItem(item) : ServerAPIRoom.Playlist[i]).ToArray();\r\n\r\n            await ((IMultiplayerClient)this).PlaylistItemChanged(clone(item)).ConfigureAwait(false);\r\n        }\r\n\r\n        public override Task EditPlaylistItem(MultiplayerPlaylistItem item) => EditUserPlaylistItem(api.LocalUser.Value.OnlineID, clone(item));\r\n\r\n        public async Task RemoveUserPlaylistItem(int userId, long playlistItemId)\r\n        {\r\n            Debug.Assert(ServerRoom != null);\r\n            Debug.Assert(ServerAPIRoom != null);\r\n\r\n            var item = ServerRoom.Playlist.FirstOrDefault(i => i.ID == playlistItemId);\r\n\r\n            if (item == null)\r\n                throw new InvalidOperationException(\"Item does not exist in the room.\");\r\n\r\n            if (item.Equals(currentItem))\r\n                throw new InvalidOperationException(\"The room's current item cannot be removed.\");\r\n\r\n            if (item.OwnerID != userId)\r\n                throw new InvalidOperationException(\"Attempted to remove an item which is not owned by the user.\");\r\n\r\n            if (item.Expired)\r\n                throw new InvalidOperationException(\"Attempted to remove an item which has already been played.\");\r\n\r\n            ServerRoom.Playlist.Remove(item);\r\n            ServerAPIRoom.Playlist = ServerAPIRoom.Playlist.Where(i => i.ID != item.ID).ToArray();\r\n            await ((IMultiplayerClient)this).PlaylistItemRemoved(clone(playlistItemId)).ConfigureAwait(false);\r\n\r\n            await updateCurrentItem(ServerRoom).ConfigureAwait(false);\r\n            updateRoomStateIfRequired();\r\n        }\r\n\r","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs#L575-L611","documentation":"RemoveUserPlaylistItem throws when no playlist item matches the given playlistItemId, mirroring the server's removal precondition. The lookup uses FirstOrDefault on ServerRoom.Playlist.","triggerScenarios":"Calling RemovePlaylistItem/RemoveUserPlaylistItem with an ID not present in ServerRoom.Playlist.","commonSituations":"Removing an item twice; removing by a stale or cloned ID; the item was already removed by another user/step.","solutions":["Pass an ID known to exist in ServerRoom.Playlist.","Re-query ServerRoom.Playlist for a valid ID before removing.","Guard against double-removal by checking existence first."],"exampleFix":"// before\nawait client.RemovePlaylistItem(999); // not present\n\n// after\nlong id = client.ServerRoom.Playlist.First(i => !i.Expired && i.ID != currentItem?.ID).ID;\nawait client.RemovePlaylistItem(id);","handlingStrategy":"validation","validationCode":"if (!ServerRoom.Playlist.Any(i => i.ID == playlistItemId))\n    throw new InvalidOperationException($\"no playlist item {playlistItemId}\");\nawait client.RemovePlaylistItem(playlistItemId);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source removal IDs from ServerRoom.Playlist.","Guard against double-removal across test steps.","Re-query the playlist if other users may have removed items."],"tags":["test-infra","multiplayer","playlist","validation"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}