diff --git a/litestar/handlers/http_handlers/base.py b/litestar/handlers/http_handlers/base.py index f67127a510..b04a66ede0 100644 --- a/litestar/handlers/http_handlers/base.py +++ b/litestar/handlers/http_handlers/base.py @@ -710,21 +710,16 @@ async def _get_response_data(self, request: Request) -> tuple[Any, DependencyCle parameter_model = self._get_kwargs_model_for_route(request.scope["path_params"].keys()) if parameter_model.has_kwargs and self.signature_model: - kwargs = parameter_model.to_kwargs(connection=request) + try: + kwargs = await parameter_model.to_kwargs(connection=request) + except SerializationException as e: + raise ClientException(str(e)) from e if "data" in kwargs: - try: - data = await kwargs["data"] - except SerializationException as e: - raise ClientException(str(e)) from e + data = kwargs["data"] if data is Empty: del kwargs["data"] - else: - kwargs["data"] = data - - if "body" in kwargs: - kwargs["body"] = await kwargs["body"] if parameter_model.dependency_batches: cleanup_group = await parameter_model.resolve_dependencies(request, kwargs) diff --git a/litestar/handlers/websocket_handlers/route_handler.py b/litestar/handlers/websocket_handlers/route_handler.py index 0a4ca0c851..e5991836ee 100644 --- a/litestar/handlers/websocket_handlers/route_handler.py +++ b/litestar/handlers/websocket_handlers/route_handler.py @@ -129,7 +129,7 @@ async def handle(self, connection: WebSocket[Any, Any, Any]) -> None: cleanup_group: DependencyCleanupGroup | None = None if handler_parameter_model.has_kwargs and self.signature_model: - parsed_kwargs = handler_parameter_model.to_kwargs(connection=connection) + parsed_kwargs = await handler_parameter_model.to_kwargs(connection=connection) if handler_parameter_model.dependency_batches: cleanup_group = await handler_parameter_model.resolve_dependencies(connection, parsed_kwargs)