fix(telegram): improve error messages for 403 bot not member errors#53635
fix(telegram): improve error messages for 403 bot not member errors#53635obviyus merged 6 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR improves
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: extensions/telegram/src/send.ts
Line: 497
Comment:
**"bot was kicked" case not covered**
The regex handles `bot.*not.*member` and `bot.*blocked`, but Telegram also emits `403: Forbidden: bot was kicked from the group chat` (and supergroup/channel variants). These errors currently fall through to `return err` (raw, cryptic error), just as before this PR.
Consider extending the alternation to cover kicks as well:
```suggestion
if (/403.*(bot.*not.*member|bot.*blocked|bot.*kicked)/i.test(errorMsg)) {
```
And update the user-facing message to mention removal/kicking alongside "not a member".
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: 497-505
Comment:
**No test coverage for new 403 path**
The existing `400: Bad Request: chat not found` branch is covered by the `"wraps chat-not-found with actionable context"` test suite in `send.test.ts` (line 1814). The new `403` branch has no corresponding test cases.
Adding a test that mocks a rejection with e.g. `new Error("403: Forbidden: bot is not a member of the channel chat")` and asserts that the thrown message contains the actionable hint would prevent future regressions here.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(telegram): correct regex alternation..." | Re-trigger Greptile |
| const errorMsg = formatErrorMessage(err); | ||
|
|
||
| // Check for 403 "bot is not a member" or "bot was blocked" errors | ||
| if (/403.*(bot.*not.*member|bot.*blocked)/i.test(errorMsg)) { |
There was a problem hiding this comment.
"bot was kicked" case not covered
The regex handles bot.*not.*member and bot.*blocked, but Telegram also emits 403: Forbidden: bot was kicked from the group chat (and supergroup/channel variants). These errors currently fall through to return err (raw, cryptic error), just as before this PR.
Consider extending the alternation to cover kicks as well:
| if (/403.*(bot.*not.*member|bot.*blocked)/i.test(errorMsg)) { | |
| if (/403.*(bot.*not.*member|bot.*blocked|bot.*kicked)/i.test(errorMsg)) { |
And update the user-facing message to mention removal/kicking alongside "not a member".
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/telegram/src/send.ts
Line: 497
Comment:
**"bot was kicked" case not covered**
The regex handles `bot.*not.*member` and `bot.*blocked`, but Telegram also emits `403: Forbidden: bot was kicked from the group chat` (and supergroup/channel variants). These errors currently fall through to `return err` (raw, cryptic error), just as before this PR.
Consider extending the alternation to cover kicks as well:
```suggestion
if (/403.*(bot.*not.*member|bot.*blocked|bot.*kicked)/i.test(errorMsg)) {
```
And update the user-facing message to mention removal/kicking alongside "not a member".
How can I resolve this? If you propose a fix, please make it concise.| if (/403.*(bot.*not.*member|bot.*blocked)/i.test(errorMsg)) { | ||
| return new Error( | ||
| [ | ||
| `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(" "), | ||
| ); | ||
| } |
There was a problem hiding this comment.
No test coverage for new 403 path
The existing 400: Bad Request: chat not found branch is covered by the "wraps chat-not-found with actionable context" test suite in send.test.ts (line 1814). The new 403 branch has no corresponding test cases.
Adding a test that mocks a rejection with e.g. new Error("403: Forbidden: bot is not a member of the channel chat") and asserts that the thrown message contains the actionable hint would prevent future regressions here.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/telegram/src/send.ts
Line: 497-505
Comment:
**No test coverage for new 403 path**
The existing `400: Bad Request: chat not found` branch is covered by the `"wraps chat-not-found with actionable context"` test suite in `send.test.ts` (line 1814). The new `403` branch has no corresponding test cases.
Adding a test that mocks a rejection with e.g. `new Error("403: Forbidden: bot is not a member of the channel chat")` and asserts that the thrown message contains the actionable hint would prevent future regressions here.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4fa7211177
ℹ️ 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".
| `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.", |
There was a problem hiding this comment.
Preserve permanent-error tokens in wrapped 403 failures
This replacement message drops Telegram’s original phrases (for example, bot was blocked by the user / forbidden: bot was kicked) that downstream classifiers use to mark delivery errors as permanent, so these 403 membership/blocking failures can now be misclassified as retryable. I checked src/infra/outbound/delivery-queue.ts and src/agents/subagent-announce.ts, where permanent matching relies on those original substrings; with this new text, blocked/not-member errors can be retried unnecessarily until retry limits instead of being handled as terminal failures.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89d816e3c6
ℹ️ 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".
| `Telegram send failed: bot is not a member of the chat, was blocked, or was kicked (chat_id=${params.chatId}).`, | ||
| "Fix: Add the bot to the channel/group, or ensure it has not been removed/blocked/kicked by the user.", |
There was a problem hiding this comment.
Preserve Telegram forbidden substrings in wrapped errors
When a Telegram send fails with a 403 blocked/kicked/not-member error, this wrapper replaces the original provider text with a new message that no longer contains the tokens our permanent-error classifiers match (for example bot was blocked by the user / forbidden: bot was kicked). I checked src/infra/outbound/delivery-queue-recovery.ts, src/agents/subagent-announce.ts, and src/cron/isolated-agent/delivery-dispatch.ts; each uses those substrings to avoid retries, so these failures can now be misclassified as retryable and churn through retry loops instead of being treated as terminal.
Useful? React with 👍 / 👎.
- 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
- 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
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
… (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 <hi@obviy.us>
Restored PR #48650