From 937b951727ebb2c193d4228efd66e0a1c75c07bf Mon Sep 17 00:00:00 2001 From: Alejandro Rivera Date: Sat, 8 Aug 2020 01:56:39 -0700 Subject: [PATCH] Fix rest_command UnboundLocalError in exception handling (#38656) ``` 2020-08-07 22:38:10 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.3903193064] local variable 'response' referenced before assignment Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/rest_command/__init__.py", line 115, in async_service_handler async with getattr(websession, method)( File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__ self._resp = await self._coro File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request break File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 586, in __exit__ raise asyncio.TimeoutError from None asyncio.exceptions.TimeoutError During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 125, in handle_call_service await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 1281, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1316, in _execute_service await handler.func(service_call) File "/usr/src/homeassistant/homeassistant/components/rest_command/__init__.py", line 137, in async_service_handler _LOGGER.warning("Timeout call %s", response.url, exc_info=1) UnboundLocalError: local variable 'response' referenced before assignment ``` --- homeassistant/components/rest_command/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/rest_command/__init__.py b/homeassistant/components/rest_command/__init__.py index f8b99c48a44..1290912897d 100644 --- a/homeassistant/components/rest_command/__init__.py +++ b/homeassistant/components/rest_command/__init__.py @@ -134,7 +134,7 @@ async def async_setup(hass, config): ) except asyncio.TimeoutError: - _LOGGER.warning("Timeout call %s", response.url, exc_info=1) + _LOGGER.warning("Timeout call %s", request_url, exc_info=1) except aiohttp.ClientError: _LOGGER.error("Client error %s", request_url, exc_info=1)