Repository navigation
ManagedWebSocket: report actual messageType in invalid-type ArgumentException - #129069
Merged
Merged
Conversation
…Exception Co-authored-by: MihaZupan <[email protected]>
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
MihaZupan
marked this pull request as ready for review
June 6, 2026 13:34
MihaZupan
enabled auto-merge (squash)
June 6, 2026 13:34
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 <[email protected]>
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
MihaZupan
enabled auto-merge (squash)
June 6, 2026 15:45
rzikm
approved these changes
Jun 16, 2026
eiriktsarpalis
pushed a commit
that referenced
this pull request
Jul 15, 2026
…xception (#129069) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MihaZupan <[email protected]>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.