dont log err.headers which can contain sensitive info

This commit is contained in:
Mikhail Epifanov
2024-09-13 22:36:05 +02:00
parent 145abfa344
commit 8c8834e6aa

View File

@@ -3,7 +3,7 @@ from logging import Logger
from typing import Dict, Tuple from typing import Dict, Tuple
from urllib.parse import urljoin from urllib.parse import urljoin
from aiohttp import ClientError, request from aiohttp import request, ClientResponseError
from cookbook.connectors.connector import Connector from cookbook.connectors.connector import Connector
from cookbook.models import ShoppingListEntry, ConnectorConfig, Space from cookbook.models import ShoppingListEntry, ConnectorConfig, Space
@@ -48,8 +48,8 @@ class HomeAssistant(Connector):
try: try:
await self.homeassistant_api_call("POST", "services/todo/add_item", data) await self.homeassistant_api_call("POST", "services/todo/add_item", data)
except ClientError as err: except ClientResponseError as err:
self._logger.warning(f"received an exception from the api: {err=}, {type(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: 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: if not self._config.on_shopping_list_entry_updated_enabled:
@@ -76,9 +76,9 @@ class HomeAssistant(Connector):
try: try:
await self.homeassistant_api_call("POST", "services/todo/remove_item", data) 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 # 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: async def close(self) -> None:
pass pass