ManagedWebSocket: report actual messageType in invalid-type ArgumentException#129069
Open
Copilot wants to merge 3 commits into
Open
ManagedWebSocket: report actual messageType in invalid-type ArgumentException#129069Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
…Exception Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix actual invalid input reporting in ThrowIfInvalidMessageType
ManagedWebSocket: report actual messageType in invalid-type ArgumentException
Jun 6, 2026
Contributor
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
MihaZupan
approved these changes
Jun 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates ManagedWebSocket.ThrowIfInvalidMessageType so the ArgumentException message reports the actual invalid WebSocketMessageType value provided by the caller (including undefined enum values), rather than always reporting "Close".
Changes:
- Passes the
messageTypeargument through to theSR.Formatplaceholder for the invalid-message-type exception. - Updates the local throw helper signature to accept
messageTypeand propagate it into the formatted message.
Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
auto-merge was automatically disabled
June 6, 2026 14:15
Head branch was pushed to by a user without write access
MihaZupan
approved these changes
Jun 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ManagedWebSocket.ThrowIfInvalidMessageTypehardcoded"Close"into theArgumentExceptionmessage regardless of the value supplied by the caller, so e.g.SendAsync(..., (WebSocketMessageType)999, ...)produced a misleading"The message type 'Close' is not allowed...".messageTypethrough to theSR.Formatcall (placeholder{0}) insrc/libraries/System.Net.WebSockets/src/System/Net/WebSockets/ManagedWebSocket.cs, replacing the hardcodednameof(WebSocketMessageType.Close).BrowserWebSocket.SendAsyncalready does, so behavior is now consistent across implementations and future-proof against newWebSocketMessageTypevalues.