Skip to content

fix(telegram): report inbound media download failures - #100051

Merged
steipete merged 1 commit into
mainfrom
codex/telegram-getfile-failures
Jul 4, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/telegram-getfile-failures

Conversation

@steipete

@steipete steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Closes #100000

What Problem This Solves

Fixes an issue where Telegram users sending media would receive no diagnostic when Telegram's getFile call failed. The message could continue with only a media placeholder, while the attachment was neither saved nor delivered to the model; files above Telegram Bot API's 20 MB download ceiling hit this path consistently.

Why This Change Was Made

Inbound getFile failures now use the existing typed media-error path instead of returning null. Transient failures remain eligible for durable spool retry, Telegram retry_after is honored inside a shutdown-aware 20-minute overall deadline, static stickers follow the same failure contract, and the permanent Bot API size failure reports the lower of Telegram's 20 MB ceiling and the configured media limit.

User Impact

Telegram users now receive a reply on failed media downloads instead of a silently incomplete agent turn. Oversized files receive an accurate maximum-size warning, while transient failures—including 429 responses—retain their retryable status for spooled delivery.

Evidence

  • Focused regression suite: node scripts/run-vitest.mjs extensions/telegram/src/bot/delivery.resolve-media-retry.test.ts extensions/telegram/src/bot-handlers.media.test.ts extensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.ts — 56 tests passed.
  • Final autoreview: no accepted or actionable findings.
  • Testbox changed-surface gate: tbx_01kwq57s8g8qrxy5dvabys9yg1 — extension production/tests typecheck, lint, database/media/runtime guards, and import-cycle check passed. Actions run
  • Real Telegram baseline on current main: a 21 MiB document produced no warning, saved no inbound file, and reached the model only as a document placeholder.
  • Real Telegram final-source proof: the same 21 MiB document received ⚠️ File too large. Maximum size is 20MB., created zero model requests, and created zero inbound files. Small photo and document controls were saved and reached the model.
  • Dependency contract checked against grammY 1.43.0 source (Context.getFile(signal?), GrammyError.error_code, response parameters) and the Telegram Bot API getFile contract.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: M maintainer Maintainer-authored PR labels Jul 4, 2026
@clawsweeper

clawsweeper Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 6f753f57fffddcc8d403b6ac6174e95d6ba3a70a, but the PR head is now bde75781ecd58ce4ad469db441c917963bcd59c3. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (1 earlier review cycle)
  • reviewed 2026-07-04T18:31:53.088Z sha af37c64 :: needs maintainer review before merge. :: none

@steipete

steipete commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready maintainer proof for the exact PR head bde75781ecd58ce4ad469db441c917963bcd59c3.

What was verified:

  • Source provenance: the silent getFile() failure path was introduced by fix(telegram): stop dropping voice messages on getFile network errors (#16136) #16154 / 80abb5ab9838; it is present in v2026.4.23 and current main. The reported symptom is valid, but the evidence does not support a new June 29 source regression.
  • Dependency contract: grammY 1.43.0 exposes Context.getFile(signal?); GrammyError carries error_code, description, and response parameters. Telegram's standard Bot API getFile download limit is 20 MB, so channels.telegram.mediaMaxMb cannot raise that transport limit.
  • Best-fix judgment: the resolver now has one typed failure path. Transient failures retry locally, preserve Telegram retry_after, and then enter the existing durable inbound spool; permanent Bot API size failures become the existing user-visible warning. Unsupported animated/video sticker behavior remains intentionally unchanged.
  • Lifecycle: retry sleep and getFile() are bounded by the Telegram session shutdown signal and a 20-minute aggregate deadline. Cancellation preserves the original classified failure for durable retry decisions.
  • Autofix/review: fresh autoreview completed with no accepted or actionable findings.

Validation:

Known proof gaps: none for the standard Telegram Bot API path changed here. The separate local Bot API trusted-root path in #91984 is intentionally out of scope.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af37c64282

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

MediaFetchError,
resolveTelegramApiBase,
retryAsync,
sleepWithAbort,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the media runtime mocks aligned

This swaps the runtime seam from retryAsync to sleepWithAbort, but the existing Vitest mocks in extensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.ts:18 and extensions/telegram/src/bot.create-telegram-bot.media-group-skip-warning.test.ts:17 still return retryAsync/warn and no sleepWithAbort. Those suites import bot-core → bot-handlers.runtime → delivery.resolve-media, so Vitest will load the mocked runtime without the newly required export (or leave the retry sleep undefined on the new getFile failure path) until the mocks provide sleepWithAbort.

Useful? React with 👍 / 👎.

@steipete
steipete requested a review from a team as a code owner July 4, 2026 18:43
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: slack Channel integration: slack channel: voice-call Channel integration: voice-call app: ios App: ios app: macos App: macos app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: acpx extensions: byteplus extensions: volcengine channel: qqbot extensions: qa-lab extensions: codex plugin: file-transfer and removed size: M labels Jul 4, 2026
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph guard cleared

This PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh /allow-dependencies-change comment after the guard blocks that new head SHA.

  • Current SHA: bde75781ecd58ce4ad469db441c917963bcd59c3

@github-actions github-actions Bot removed the dependencies-changed PR changes dependency-related files label Jul 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bde75781ec

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 1427 to +1430
getFile: async () => await bot.api.getFile(replyFileId),
},
maxBytes: mediaMaxBytes,
...mediaRuntimeOptions,
...mediaRuntimeWithAbort,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Forward abort signals for hydrated reply media

When hydrating media from a replied-to message, this synthetic getFile ignores the signal that resolveMedia now passes in, even though grammY 1.43.0 supports api.getFile(file_id, signal?). For replies to prior media, a stuck or long getFile request will therefore bypass the new shutdown/deadline cancellation path and can keep the handler/spooled replay blocked instead of aborting like current-message media does; accept the signal here and pass it to bot.api.getFile.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 77f0f40 into main Jul 4, 2026
108 of 114 checks passed
@steipete
steipete deleted the codex/telegram-getfile-failures branch July 4, 2026 18:54
@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Telegram inbound media — files never saved to media/inbound, no error logged (regression, 2026.4.23)

1 participant