From b79886ad8582d0eab97ea1a63f3fa44888cbe441 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Tue, 14 May 2019 02:12:05 -0500 Subject: [PATCH] Fix improper usage of body attribute on web.Response. Should be text since we arent sending bytes (#23857) --- homeassistant/components/geofency/__init__.py | 2 +- homeassistant/components/locative/__init__.py | 4 ++-- homeassistant/components/mobile_app/helpers.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/geofency/__init__.py b/homeassistant/components/geofency/__init__.py index 0b4b757ce9e..57eaf5393ae 100644 --- a/homeassistant/components/geofency/__init__.py +++ b/homeassistant/components/geofency/__init__.py @@ -72,7 +72,7 @@ async def handle_webhook(hass, webhook_id, request): data = WEBHOOK_SCHEMA(dict(await request.post())) except vol.MultipleInvalid as error: return web.Response( - body=error.error_message, + text=error.error_message, status=HTTP_UNPROCESSABLE_ENTITY ) diff --git a/homeassistant/components/locative/__init__.py b/homeassistant/components/locative/__init__.py index f21c55af28a..50e6f69b0bd 100644 --- a/homeassistant/components/locative/__init__.py +++ b/homeassistant/components/locative/__init__.py @@ -58,7 +58,7 @@ async def handle_webhook(hass, webhook_id, request): data = WEBHOOK_SCHEMA(dict(await request.post())) except vol.MultipleInvalid as error: return web.Response( - body=error.error_message, + text=error.error_message, status=HTTP_UNPROCESSABLE_ENTITY ) @@ -76,7 +76,7 @@ async def handle_webhook(hass, webhook_id, request): location_name ) return web.Response( - body='Setting location to {}'.format(location_name), + text='Setting location to {}'.format(location_name), status=HTTP_OK ) diff --git a/homeassistant/components/mobile_app/helpers.py b/homeassistant/components/mobile_app/helpers.py index ee593588ef8..6aec4307464 100644 --- a/homeassistant/components/mobile_app/helpers.py +++ b/homeassistant/components/mobile_app/helpers.py @@ -81,7 +81,7 @@ def registration_context(registration: Dict) -> Context: def empty_okay_response(headers: Dict = None, status: int = 200) -> Response: """Return a Response with empty JSON object and a 200.""" - return Response(body='{}', status=status, content_type='application/json', + return Response(text='{}', status=status, content_type='application/json', headers=headers)