[possible bug] 'code' is not labeled as optional
See original GitHub issueIn https://asgi.readthedocs.io/en/latest/specs/www.html#disconnect-receive-event-ws it does not say code is optional, yet it says “as per websocket spec”, where code is optional (“may contain”). Later on in Close - send event it explicitly mentions that the code there is optional. In the first link should code be optional or required?
If code is optional I would be happy to submit a PR to this repo to update the docs.
This is not just a theoretical question, as we are facing a bug that may be related to this. In https://github.com/django/channels/blob/38324816c115567e198a573bc294d8345df5e8a9/channels/generic/websocket.py#L105 channels assumes that the code key exists, but in our case it doesn’t exist and a KeyError is raised.
Issue Analytics
- State:
- Created a year ago
- Comments:16 (13 by maintainers)
Top Results From Across the Web
Optional value should only be accessed after calling isPresent()
NoSuchElementException if there is no value present. To avoid the exception, calling the isPresent() or ! isEmpty() method should always be done before...
Read more >Buf does not allow optional fields in extensions with proto3 #217
I'm getting a label 'optional' is not allowed on extensions in proto3 error for a code like this: // Validation rules applied at...
Read more >parameter is required by @ Test but has not been marked ...
Parameter 'Visit' is required by @Test on method searchByVisitNo but has not been marked @Optional or defined. I don't know why is there...
Read more >Error codes for optional checks - mypy 0.991 documentation
Error codes for optional checks#. This section documents various errors codes that mypy generates only if you enable certain options. See Error codes...
Read more >How to Deal with Optional Things and "Undefined" in TypeScript
First, if you don't tell TypeScript that a property is optional, it will expect it to be set. Adding ? to the property...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@carltongibson, sure. I figure I might as well make the proposal a PR because the change is so easy to make: https://github.com/django/channels/pull/1905
Yeah, both of those should be, since they are
disconnect.disconnect= 1005,close= 1000 as defaults.