fix(telegram): improve error messages for 403 bot not member errors#48650
fix(telegram): improve error messages for 403 bot not member errors#48650w-sss wants to merge 3 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR improves error messaging in the Telegram Key issues:
Confidence Score: 3/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/telegram/src/send.ts
Line: 497
Comment:
**Regex alternation precedence matches non-403 errors**
Due to how regex `|` alternation works, this pattern has two alternatives:
1. `403.*bot.*not.*member`
2. `bot.*blocked`
The second alternative has no `403` prefix requirement, meaning **any** error message that contains `"bot"` followed by `"blocked"` will match this branch — even if it's a 404, 500, or some other non-403 error. This would incorrectly return the "bot is not a member" message for unrelated errors.
The fix is to group the two alternatives and require `403` for both:
```suggestion
if (/403.*(bot.*not.*member|bot.*blocked)/i.test(errorMsg)) {
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/telegram/src/send.ts
Line: 499-503
Comment:
**Misleading fix suggestion for "bot was blocked" case**
The regex matches two distinct Telegram 403 scenarios:
- `"bot is not a member of the channel chat"` — bot was never added to the channel/group.
- `"bot was blocked by the user"` — a user in a DM has blocked the bot.
For the second case, the error message `"bot is not a member of the chat"` and the suggestion `"Add the bot to the channel/group"` are misleading — in a blocked-by-user DM context, adding the bot to a group is not the right fix.
Consider branching the two cases, or at minimum broadening the error text to cover both scenarios, e.g.:
```suggestion
`Telegram send failed: bot is not a member of the chat or has been blocked (chat_id=${params.chatId}).`,
"Fix: Add the bot to the channel/group, ensure it has not been removed, or ask the user to unblock the bot.",
`Input was: ${JSON.stringify(params.input)}.`,
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 8ef89ac |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ef89acee4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb2b52ab2d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Detect 403 'bot is not a member' errors specifically - Provide actionable guidance for users to fix the issue - Fixes openclaw#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
- 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
bb2b52a to
e9c69ff
Compare
- Detect 403 'bot is not a member' and 'bot was blocked' errors - Provide actionable guidance for users to fix the issue - Group regex alternatives correctly: /403.*(bot.*not.*member|bot.*blocked)/i - Fixes openclaw#48273 Addresses Greptile/Codex review feedback on PR openclaw#48650
- Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650
- Detect 403 'bot is not a member' and 'bot was blocked' errors - Provide actionable guidance for users to fix the issue - Group regex alternatives correctly: /403.*(bot.*not.*member|bot.*blocked)/i - Fixes openclaw#48273 Addresses Greptile/Codex review feedback on PR openclaw#48650
📊 CI 状态说明当前失败: extension-fast (telegram), macos 原因分析:
建议: 可以安全合并,CI 失败与本 PR 无关。 |
🔧 CI 修复进展已创建 PR #53245 修复仓库依赖问题:
状态: 等待维护者审核合并 合并后本 PR 的 CI 将自动变绿。 |
- Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650
- Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650
- Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650
…w-sss) * 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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR #48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
… (thanks @w-sss) * 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 openclaw#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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (openclaw#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
… (thanks @w-sss) * 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 openclaw#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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (openclaw#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
… (thanks @w-sss) * 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 openclaw#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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (openclaw#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
… (thanks @w-sss) * 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 openclaw#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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (openclaw#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
… (thanks @w-sss) * 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 openclaw#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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (openclaw#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
… (thanks @w-sss) * 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 openclaw#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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (openclaw#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
… (thanks @w-sss) * 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 openclaw#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 * 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 * fix(telegram): correct regex alternation precedence for 403 errors - Fix: /403.*(bot.*not.*member|bot was blocked)/ → /403.*(bot.*not.*member|bot.*blocked)/ - Ensures 403 requirement applies to both alternatives - Fixes Greptile review comment on PR openclaw#48650 * fix(telegram): add 'bot was kicked' to 403 error regex and message * fix(telegram): preserve membership delivery errors * fix: improve Telegram 403 membership delivery errors (openclaw#53635) (thanks @w-sss) --------- Co-authored-by: Ayaan Zaidi <[email protected]>
Summary
Fixes #48273 - Telegram outbound sendMessage fails with 403 error
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
Testing
Related Issue
Fixes #48273