From 652ef4849e7ea186672fc9dd301849b6747f6722 Mon Sep 17 00:00:00 2001 From: Cao Hanzhe Date: Fri, 8 May 2026 23:10:27 +0800 Subject: [PATCH 1/2] fix: retry Telegram message without parse_mode on Markdown parsing failure When alert text contains unescaped Markdown special characters (e.g. underscores in Kubernetes pod names like 'crowdsec-agent_k8vkt'), the Telegram API rejects the message with a 'can't parse entities' error. This change adds a fallback mechanism: if sending with parse_mode='Markdown' fails, the message is retried without any parse_mode so it is delivered as plain text rather than being silently dropped. Fixes #1982 --- src/robusta/core/sinks/telegram/telegram_client.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/robusta/core/sinks/telegram/telegram_client.py b/src/robusta/core/sinks/telegram/telegram_client.py index fb23d34a4..9bb766edc 100644 --- a/src/robusta/core/sinks/telegram/telegram_client.py +++ b/src/robusta/core/sinks/telegram/telegram_client.py @@ -27,9 +27,18 @@ def send_message(self, message: str, disable_links_preview: bool = True): response = requests.post(url, json=message_json) if response.status_code != 200: - logging.error( - f"Failed to send telegram message: chat_id - {self.chat_id} reason - {response.reason} {response.text}" + logging.warning( + f"Failed to send telegram message with Markdown parse_mode: chat_id - {self.chat_id} " + f"reason - {response.reason} {response.text}. Retrying without parse_mode." ) + # Retry without parse_mode to handle messages with unescaped Markdown characters + message_json.pop("parse_mode", None) + response = requests.post(url, json=message_json) + + if response.status_code != 200: + logging.error( + f"Failed to send telegram message: chat_id - {self.chat_id} reason - {response.reason} {response.text}" + ) def send_file(self, file_name: str, contents: bytes): file_type = "Photo" if is_image(file_name) else "Document" From b0e427a27249446d0b7604cbfe214ab2ba61da1b Mon Sep 17 00:00:00 2001 From: Cao Hanzhe Date: Sat, 9 May 2026 09:50:53 +0800 Subject: [PATCH 2/2] chore: trigger CLA recheck