-
-
Notifications
You must be signed in to change notification settings - Fork 478
Description
Description
In the websocket_listener decorator function, located in litestar/handlers/websocket_handlers/listener.py, there appears to be a typo when passing the guards parameter to the WebsocketListenerRouteHandler constructor.
The websocket_listener decorator's signature correctly defines a parameter named guards:
guards: list[Guard] | None = None,However, within the decorator function inside websocket_listener, when WebsocketListenerRouteHandler is instantiated, the guards parameter is passed as guard (singular):
guard=guards,The WebsocketListenerRouteHandler constructor (which inherits from WebsocketRouteHandler, which in turn inherits from BaseRouteHandler) expects a parameter named guards (plural). This mismatch will likely lead to a runtime error, such as a TypeError if WebsocketListenerRouteHandler doesn't have a guard parameter, or the guards configuration will simply be ignored if guard is implicitly caught by **kwargs and then not processed correctly.
Impact:
- Any guards defined for a websocket_listener will not be correctly applied to the WebsocketListenerRouteHandler.
- The application might raise a TypeError during startup or when attempting to register the websocket listener, depending on how argument parsing is handled in the WebsocketListenerRouteHandler constructor and its parent classes.
Solution:
Change guard=guards to guards=guards in the websocket_listener decorator function to correctly pass the guards parameter to the WebsocketListenerRouteHandler constructor.
URL to code causing the issue
No response
MCVE
Steps to reproduce
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Screenshots
No response
Logs
Litestar Version
2.18.0
Platform
- Linux
- Mac
- Windows
- Other (Please specify in the description above)