From 7903348d791571a29e5b3d621537892b313b6afa Mon Sep 17 00:00:00 2001 From: Daniel O'Connor Date: Mon, 10 Feb 2025 20:17:02 +1030 Subject: [PATCH] Prevent crash if telegram message failed and did not generate an ID (#137989) Fix #137901 - Regression introduced in 6fdccda2256f92c824a98712ef102b4a77140126 --- homeassistant/components/telegram_bot/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/telegram_bot/__init__.py b/homeassistant/components/telegram_bot/__init__.py index fa3ec1dc4f7..b3c09049ae5 100644 --- a/homeassistant/components/telegram_bot/__init__.py +++ b/homeassistant/components/telegram_bot/__init__.py @@ -756,7 +756,8 @@ class TelegramNotificationService: message_thread_id=params[ATTR_MESSAGE_THREAD_ID], context=context, ) - msg_ids[chat_id] = msg.id + if msg is not None: + msg_ids[chat_id] = msg.id return msg_ids async def delete_message(self, chat_id=None, context=None, **kwargs):