From a7382c80923fcc52a9cbf38335943f4124b4146a Mon Sep 17 00:00:00 2001 From: Cliffano Subagio <cliffano@gmail.com> Date: Tue, 23 Nov 2021 00:38:36 +1100 Subject: [PATCH] Fix KeyError when Twitter app permission is set to Read (#60018) --- homeassistant/components/twitter/notify.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/twitter/notify.py b/homeassistant/components/twitter/notify.py index 54aaf2142e5..fd97303a360 100644 --- a/homeassistant/components/twitter/notify.py +++ b/homeassistant/components/twitter/notify.py @@ -243,7 +243,12 @@ class TwitterNotificationService(BaseNotificationService): def log_error_resp(resp): """Log error response.""" obj = json.loads(resp.text) - error_message = obj["errors"] + if "errors" in obj: + error_message = obj["errors"] + elif "error" in obj: + error_message = obj["error"] + else: + error_message = resp.text _LOGGER.error("Error %s: %s", resp.status_code, error_message) @staticmethod -- GitLab