Skip to content

Commit

Permalink
fix: make payload:null handling in connection_init consistent between…
Browse files Browse the repository at this point in the history
… protocols
  • Loading branch information
Object905 committed Dec 28, 2024
1 parent e78f8c6 commit 09effc9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ async def handle_connection_init(self, message: ConnectionInitMessage) -> None:
self.connection_init_timeout_task.cancel()

payload = message.get("payload", {})

if payload is None:
payload = {}
if not isinstance(payload, dict):
await self.websocket.close(
code=4400, reason="Invalid connection init payload"
Expand Down
4 changes: 3 additions & 1 deletion strawberry/subscriptions/protocols/graphql_ws/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ async def handle_message(

async def handle_connection_init(self, message: ConnectionInitMessage) -> None:
payload = message.get("payload")
if payload is not None and not isinstance(payload, dict):
if payload is None:
payload = {}
if not isinstance(payload, dict):
await self.send_message({"type": "connection_error"})
await self.websocket.close(code=1000, reason="")
return
Expand Down

0 comments on commit 09effc9

Please sign in to comment.