You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ManagedWebSocket: ThrowIfInvalidMessageType: ArgumentException should report actual invalid input, not assume all invalids are 'Close' #129066
The issue is that the ArgumentException (resource string) reports that any invalid message type was "Close".
It should report the actual invalid value that was passed, which could be Close or any other WebSocketMessageType. This could be an arbitrary invalid value, e.g. 999.
It is true that the only 3 valid types are currently Text, Binary, and Close.
I don't believe it should be hard-coded to Close, because:
It is possible that WebSocket will add new message types in the future. This is a tricky place to have to update.
It is possible to pass an invalid value (e.g. 999) by parsing or casting. I did this intentionally to test my code on invalid inputs, but it is conceivable it could happen accidentally.
System.ArgumentException: The message type '999' is not allowed for the 'SendAsync' operation. Valid message types are: 'Binary, Text'. To close the WebSocket, use the 'CloseOutputAsync' operation instead. (Parameter 'messageType')
Actual behavior
System.ArgumentException: The message type 'Close' is not allowed for the 'SendAsync' operation. Valid message types are: 'Binary, Text'. To close the WebSocket, use the 'CloseOutputAsync' operation instead. (Parameter 'messageType')
Activity
dotnet-policy-service commentedon Jun 6, 2026
Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.