From 8c8834e6aa0a166f97bbc14e7e9d066705684828 Mon Sep 17 00:00:00 2001 From: Mikhail Epifanov Date: Fri, 13 Sep 2024 22:36:05 +0200 Subject: [PATCH] dont log err.headers which can contain sensitive info --- cookbook/connectors/homeassistant.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cookbook/connectors/homeassistant.py b/cookbook/connectors/homeassistant.py index e2bdcc22d..3268c4cb1 100644 --- a/cookbook/connectors/homeassistant.py +++ b/cookbook/connectors/homeassistant.py @@ -3,7 +3,7 @@ from logging import Logger from typing import Dict, Tuple from urllib.parse import urljoin -from aiohttp import ClientError, request +from aiohttp import request, ClientResponseError from cookbook.connectors.connector import Connector from cookbook.models import ShoppingListEntry, ConnectorConfig, Space @@ -48,8 +48,8 @@ class HomeAssistant(Connector): try: await self.homeassistant_api_call("POST", "services/todo/add_item", data) - except ClientError as err: - self._logger.warning(f"received an exception from the api: {err=}, {type(err)=}") + except ClientResponseError as err: + self._logger.warning(f"received an exception from the api: {err.request_info.url=}, {err.request_info.method=}, {err.status=}, {err.message=}, {type(err)=}") async def on_shopping_list_entry_updated(self, space: Space, shopping_list_entry: ShoppingListEntry) -> None: if not self._config.on_shopping_list_entry_updated_enabled: @@ -76,9 +76,9 @@ class HomeAssistant(Connector): try: await self.homeassistant_api_call("POST", "services/todo/remove_item", data) - except ClientError as err: + except ClientResponseError as err: # This error will always trigger if the item is not present/found - self._logger.debug(f"received an exception from the api: {err=}, {type(err)=}") + self._logger.debug(f"received an exception from the api: {err.request_info.url=}, {err.request_info.method=}, {err.status=}, {err.message=}, {type(err)=}") async def close(self) -> None: pass