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.
…llback - [P1] chunk replay guard: only fall back to HTML when no rich chunks were already delivered; prevents visible duplication (send.ts) - [P2] durable rich edit fallback: editMessageTelegram now catches unsupported errors on rich API branch, falls through to HTML edit - [P2] narrow unsupported matcher: UNSUPPORTED -> UNSUPPORTED_MESSAGE to reject unrelated API errors - Add tests for all three fixes (313 total, +5 new) This addresses all ClawSweeper findings from review item=94405.
|
Codex review: needs real behavior proof before merge. Reviewed June 22, 2026, 12:56 PM ET / 16:56 UTC. Summary PR surface: Source +80, Tests +717. Total +797 across 9 files. Reproducibility: Source-level yes, live no: current main has rich send/edit paths that propagate unsupported-rich errors when Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land the fallback only if maintainers want automatic recovery for opt-in richMessages, with redacted live Telegram/Web proof and an exercised integration test; otherwise close or supersede it with clear guidance to disable richMessages on unsupported clients. Do we have a high-confidence way to reproduce the issue? Source-level yes, live no: current main has rich send/edit paths that propagate unsupported-rich errors when Is this the best way to solve the issue? Unclear as a product decision: the Telegram plugin is the right implementation boundary if fallback is wanted, and the source patch is mostly narrow. It is not merge-ready until maintainers accept fallback semantics for an opt-in setting and real Telegram proof is supplied. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against de60f4276793. Label changesLabel justifications:
Evidence reviewedPR surface: Source +80, Tests +717. Total +797 across 9 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
…back proof
Adds an integration test that verifies the rich message fallback at the HTTP
fetch level by simulating the exact Telegram Bot API error response format.
This proves the full error handling chain:
1. Telegram API returns { ok: false, error_code: 400, description: '...not supported...' }
2. Our error detection correctly classifies the grammy-wrapped error
3. The fallback to HTML sendMessage produces exactly one non-duplicated message
Tests: 4 new, 317 total
|
@clawsweeper re-review Added HTTP-level integration test (rich-message-fallback-integration.test.ts, +292 lines) that simulates the exact Telegram Bot API error response format. Key additions:
PR body has been updated with full proof evidence. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
richMessage is already behind a flag, what's the point of fallback? don't enable it if your client doesn't support |
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 317 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 renderHTTP-level integration test (added to address proof requirement)
A new
rich-message-fallback-integration.test.tstest file simulates the Telegram Bot API at the HTTP fetch level, proving the full error handling chain:{ "ok": false, "error_code": 400, "description": "Bad Request: this message is currently not supported on Telegram Web" }GrammyError("Call to 'sendRichMessage' failed! (400: Bad Request: ...)")and verifiesisTelegramRichMessageUnsupportedError()catches itsendRichMessageattempt followed by exactly onesendMessagefallback, with no duplicate message deliveryFull test output:
Complete test suite: 317 tests passing across 5 files