Repository navigation
fix(telegram): report inbound media download failures - #100051
Conversation
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
|
Land-ready maintainer proof for the exact PR head What was verified:
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. |
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
Dependency graph guard clearedThis PR no longer has blocked dependency graph changes. A future dependency graph change requires a fresh
|
There was a problem hiding this comment.
💡 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".
| getFile: async () => await bot.api.getFile(replyFileId), | ||
| }, | ||
| maxBytes: mediaMaxBytes, | ||
| ...mediaRuntimeOptions, | ||
| ...mediaRuntimeWithAbort, |
There was a problem hiding this comment.
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 👍 / 👎.
|
Merged via squash.
|
Closes #100000
What Problem This Solves
Fixes an issue where Telegram users sending media would receive no diagnostic when Telegram's
getFilecall 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
getFilefailures now use the existing typed media-error path instead of returningnull. Transient failures remain eligible for durable spool retry, Telegramretry_afteris 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
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.tbx_01kwq57s8g8qrxy5dvabys9yg1— extension production/tests typecheck, lint, database/media/runtime guards, and import-cycle check passed. Actions runmain: a 21 MiB document produced no warning, saved no inbound file, and reached the model only as a document placeholder.⚠️ 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.Context.getFile(signal?),GrammyError.error_code, response parameters) and the Telegram Bot APIgetFilecontract.