Skip to content

Commit 53d9633

Browse files
committed
fix: fail loudly on an unhandled hub lifetime result
AddLiveControlConnection returns Union3<HubLifetime, NotFound, Busy> and all three are handled, but a switch statement is not exhaustiveness-checked. If the union ever widens, the unhandled case would fall through to reporting LiveControlOutcome.Connected and returning Success with a null _hubLifetime, surfacing only later as "Hub lifetime is null but was accessed". Matches the UnreachableException default already used by the switch expressions below.
1 parent ac0d3ef commit 53d9633

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎LiveControlGateway/Controllers/LiveControlController.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ public async Task UpdatePermissions(OpenShockContext db)
238238
case LifetimeManager.HubLifetime hubLifetime:
239239
_hubLifetime = hubLifetime;
240240
break;
241+
// A switch statement is not exhaustiveness-checked, so without this an unhandled case would
242+
// fall through to reporting Connected with a null lifetime and only fail later on first access.
243+
default:
244+
throw new UnreachableException();
241245
}
242246

243247
_metrics.LiveControlAttempt(GatewayMetrics.LiveControlOutcome.Connected);

0 commit comments

Comments
 (0)