Repository navigation
Handle empty and absent payloads in WebSocketEndpoint.decode() - #3372
Conversation
There was a problem hiding this comment.
1 issue found across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
KeyError on empty text frame in WebSocketEndpoint.decode()WebSocketEndpoint.decode()
9991f71 to
91e0055
Compare
Mukller
left a comment
There was a problem hiding this comment.
Note for maintainers: this is a byte-for-byte identical fix to #3381 (same hunks in endpoints.py, same bug). I verified the before/after behavior locally — details and evidence are in my review on #3381; everything applies here too:
- main: empty text frame (
{'text': ''}) hits the falsy check →KeyError: 'bytes' - this branch: delivered as
'', 28/28 endpoint tests green
Whichever of the two you pick is correct; the other can be closed as a duplicate.
|
@Mukller thanks Claude! |
WebSocketEndpoint.decode()WebSocketEndpoint.decode()
Merging this PR will improve performance by 13.11%
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Summary
Check
Noneness instead ofTrueness in theWebSocketEndpoint.decode()method.Fixes issue in discussion #3369
Update:
Addressed a review comment.
text/bytesbranches indecode()only checked key presence ("text" not in message), not the value.ASGI spec says:
That could result in ASGI compliant message silently returning
Noneinstead of raising an error. So fixed that too.Checklist