From f0f8226fac9076dbd3fc887fd436c5285daa0ba4 Mon Sep 17 00:00:00 2001 From: w-sss <1598099293@qq.com> Date: Tue, 17 Mar 2026 00:37:37 +0800 Subject: [PATCH 1/2] fix(telegram): improve error messages for 403 bot not member errors - Detect 403 'bot is not a member' errors specifically - Provide actionable guidance for users to fix the issue - Fixes #48273 where outbound sendMessage fails with 403 Root cause: When a Telegram bot tries to send a message to a channel/group it's not a member of, the API returns 403 'bot is not a member of the channel chat'. The error message was not clear about how to fix this. Fix: 1. Detect 403 errors in wrapTelegramChatNotFoundError 2. Provide clear error message explaining the issue 3. Suggest adding the bot to the channel/group --- extensions/telegram/src/send.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/extensions/telegram/src/send.ts b/extensions/telegram/src/send.ts index 0682fda6786..d2a95941b9e 100644 --- a/extensions/telegram/src/send.ts +++ b/extensions/telegram/src/send.ts @@ -491,7 +491,20 @@ function createTelegramRequestWithDiag(params: { } function wrapTelegramChatNotFoundError(err: unknown, params: { chatId: string; input: string }) { - if (!CHAT_NOT_FOUND_RE.test(formatErrorMessage(err))) { + const errorMsg = formatErrorMessage(err); + + // Check for 403 "bot is not a member" error + if (/403.*bot.*not.*member|bot.*blocked/i.test(errorMsg)) { + return new Error( + [ + `Telegram send failed: bot is not a member of the chat (chat_id=${params.chatId}).`, + "Fix: Add the bot to the channel/group, or ensure it has not been removed/blocked.", + `Input was: ${JSON.stringify(params.input)}.`, + ].join(" "), + ); + } + + if (!CHAT_NOT_FOUND_RE.test(errorMsg)) { return err; } return new Error( From e9c69ff1df8c92bc6606ab64ec1b352b7a3fcc1b Mon Sep 17 00:00:00 2001 From: w-sss <1598099293@qq.com> Date: Tue, 17 Mar 2026 10:25:27 +0800 Subject: [PATCH 2/2] fix(telegram): fix regex precedence for 403 error detection - Group alternatives correctly: /403.*(bot.*not.*member|bot was blocked)/i - Require 403 for both alternatives (previously bot.*blocked matched any error) - Update error message to cover both scenarios - Fixes Greptile review feedback --- extensions/telegram/src/send.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extensions/telegram/src/send.ts b/extensions/telegram/src/send.ts index d2a95941b9e..8d5bc65192d 100644 --- a/extensions/telegram/src/send.ts +++ b/extensions/telegram/src/send.ts @@ -493,12 +493,12 @@ function createTelegramRequestWithDiag(params: { function wrapTelegramChatNotFoundError(err: unknown, params: { chatId: string; input: string }) { const errorMsg = formatErrorMessage(err); - // Check for 403 "bot is not a member" error - if (/403.*bot.*not.*member|bot.*blocked/i.test(errorMsg)) { + // Check for 403 "bot is not a member" or "bot was blocked" errors + if (/403.*(bot.*not.*member|bot was blocked)/i.test(errorMsg)) { return new Error( [ - `Telegram send failed: bot is not a member of the chat (chat_id=${params.chatId}).`, - "Fix: Add the bot to the channel/group, or ensure it has not been removed/blocked.", + `Telegram send failed: bot is not a member of the chat or was blocked (chat_id=${params.chatId}).`, + "Fix: Add the bot to the channel/group, or ensure it has not been removed/blocked by the user.", `Input was: ${JSON.stringify(params.input)}.`, ].join(" "), );