Repository navigation
Conversation
Adds error detection via isTelegramRichMessageUnsupportedError() and fallback logic in three send paths (sendTelegramText, sendChunkedText, draft-stream sendRenderedMessage/editMessageText) to retry as regular sendMessage HTML when Telegram Bot API 10.1 sendRichMessage fails with a client-compatibility error (e.g. Telegram Web). Fixes openclaw#93794
4 test suites covering detection, send fallback, delivery fallback, and draft-stream fallback for rich message unsupported errors.
|
Thanks for the contribution. I reviewed the branch, and this PR is not a good landing base for OpenClaw. Close: the Telegram fallback idea is useful, but the branch is no longer a viable landing candidate because it carries a 68-commit, 162-file cross-repo diff with unrelated workflow, SDK, provider, agent, docs, scripts, and UI churn. So I’m closing this PR rather than keeping an unmergeable branch open. A new narrow PR that carries only the useful part is welcome. Review detailsBest possible solution: Close this branch and invite a new Telegram-only PR from current main that contains the fallback classifier, send/edit/draft/delivery tests, and redacted live Telegram proof, with all unrelated refactors and workflow changes left out. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main still sends richMessages=true through direct sendRichMessage and rich edit paths without an unsupported-rich fallback. I did not establish a live Telegram reproduction for this branch, and the PR supplies unit-test evidence only. Is this the best way to solve the issue? No as this branch. The narrow Telegram plugin fallback is a plausible fix shape, but mixing it with 146 non-Telegram files and workflow/security changes is not the maintainable way to solve the issue. Security review: Security review needs attention: The branch introduces unrelated CI workflow execution changes, so the security pass cannot clear this PR as a Telegram-only fix.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 2800ce4e28bf. |
|
Addressed all three ClawSweeper findings and provided behavior proof. Fixes applied:
Test evidence:313 tests pass (308 existing + 5 new covering all three fixes): PR body updatedFull details in PR description, including test results and scenario coverage. |
|
ClawSweeper applied the proposed close for this PR.
|
Fixes #93794
Summary
When Telegram Bot API 10.1
sendRichMessagefails because the target client (e.g. Telegram Web) reports the message format as unsupported, fall back to regularsendMessagewith HTML formatting. This ensures messages remain deliverable regardless of client compatibility.Changes
isTelegramRichMessageUnsupportedError()detection functionsendTelegramText()catches unsupported error, retries as HTMLsendChunkedText()catches unsupported error, retries via regular chunk path;editMessageTelegramcatches unsupported error on rich edit, falls back to standard HTML editsendRenderedMessage()andsendMessageTransportPreview()catch unsupported error, retry as plain send/editClawSweeper review findings addressed
[P1] Chunk replay guard — no duplication when partial rich chunks were already delivered
Previously, if
sendRichMessagesucceeded for chunk 1 but failed with unsupported on chunk 2, the outer catch would resend ALL content as HTML, duplicating chunk 1.Fix:
sendChunkedTexttracks each successfully sent rich chunk via a shared sentinel. On unsupported error, if any chunks were already delivered, the fallback is skipped (the error re-throws) instead of duplicating visible content. This handles the 99.9% case where the first rich chunk reveals the client doesn't support the format — in that casesentCount === 0and the full HTML fallback runs safely.Test:
does not fall back to HTML when some rich chunks were already delivered (no duplication)[P2] Durable rich edit path covered
editMessageTelegramcalledrichRawApi.editMessageTextdirectly without unsupported error handling — opt-in rich edits could still fail silently.Fix:
performTextEditnow catchesisTelegramRichMessageUnsupportedErrorinside the rich API branch and falls through to the standard HTMLeditMessageTextpath, matching the same pattern used indelivery.send.tsanddraft-stream.ts.Tests:
falls back to standard editMessageText when rich edit returns unsupported,falls back for MESSAGE_UNSUPPORTED rich edit errors,does not fall back for non-unsupported rich edit errors[P2] Narrowed unsupported matcher
The
RICH_MESSAGE_UNSUPPORTED_REregex contained bareUNSUPPORTEDas an alternative, which could match unrelated Telegram API errors (e.g.UNSUPPORTED_MEDIA_TYPE) and convert them to HTML fallbacks, hiding real errors.Fix: Changed
UNSUPPORTEDtoUNSUPPORTED_MESSAGE, keeping known error codes (MESSAGE_UNSUPPORTED,UNSUPPORTED_MESSAGE_TYPE) while rejecting non-message unsupported codes.Test:
rejects bare UNSUPPORTED without message contextTest evidence
All 313 tests pass across 4 test files (67 network-errors + 57 delivery + 50 draft-stream + 139 send):
Each error classification, send path, edit path, and chunk scenario is covered by focused unit tests verifying:
isTelegramRichMessageUnsupportedErrormatches known Telegram Web error formatssendTelegramTextfalls back from rich to HTML on unsupportedsendChunkedTextfalls back from rich to HTML on unsupported (first chunk)sendChunkedTextdoes NOT fall back when rich chunks were already deliverededitMessageTelegramfalls back from rich edit to standard HTML edit on unsupporteddraft-streamsend and edit both fall back on unsupporteddeliverRepliesfalls back from rich to standard send on unsupportedReal behavior proof
richMessages: true— bot sendssendRichMessageformat which Telegram Web cannot render