Goobwabber / MultiplayerCore

A Beat Saber mod that implements core custom multiplayer functionality.
MIT License
67 stars 36 forks source link

[BUG] Uncaught exception in MpEntitlementChecker when requesting old versions of BeatSaver maps #17

Open rcelyte opened 2 years ago

rcelyte commented 2 years ago

MultiplayerCore Version 1.0.0

Your Platform PC

Describe the bug MpEntitlementChecker runs Enumerable.First() on the response received from BeatSaver, which throws instead of being handled gracefully if the requested hash isn't found. Such is the case with levels that have been revised after upload.

To Reproduce

  1. Request attached beatmap
  2. Observe other clients who don't have the song failing to respond to the entitlement check

Log

InvalidOperationException: Sequence contains no matching element
System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
MultiplayerCore.Objects.MpEntitlementChecker+<>c__DisplayClass13_0.<GetEntitlementStatus>b__0 (System.Threading.Tasks.Task`1[TResult] r) (at <ca5fd0a0d2364fa38cb3ebaefaa816a1>:0)
System.Threading.Tasks.ContinuationResultTaskFromResultTask`2[TAntecedentResult,TResult].InnerInvoke () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Threading.Tasks.Task.Execute () (at <eae584ce26bc40229c1b1aa476bfa589>:0)
...
Goobwabber commented 2 years ago

Confused on how this would happen. The Enumerable.First() I use in MpEntitlementChecker has a predicate, so it finds the first version that has a matching level hash. The only way this would happen is if BeatSaver responds with a map that doesn't actually have a version with the same hash. I'll fix the error being thrown but it seems like something else is going wrong further up the line.

Goobwabber commented 2 years ago

Fixed in a9c5991a25385fa2954da89c3f4651df6104e161, leaving issue open for later though due to reason above.