question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[possible bug] 'code' is not labeled as optional

See original GitHub issue

In 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:closed
  • Created a year ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
caleb15commented, Aug 19, 2022

@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

1reaction
andrewgodwincommented, Aug 16, 2022

Yeah, both of those should be, since they are disconnect. disconnect = 1005, close = 1000 as defaults.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found