Repository navigation
feat(telegram): send 2-10 files or attachments as one sendMediaGroup (#278) - #306
Conversation
…278) Ports vercel/chat 8d7ccdb1 (#605, chat@4.34.0) and the media-group half of d5ebec12 (#833, reply_parameters). post_message drops the single-file and single-attachment errors: one upload keeps send_document / send_attachment, 2+ go through _send_document_media_group / _send_attachment_media_group. Every returned message is cached and the last is returned. Part of #184.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…yboard-before-download, video-only integral dimensions, empty result (#278)
|
Merge gate: CI green (Lint & Type Check, test (3.12), test (3.13), Analyze (python), Analyze (actions), CodeQL); local Codex review (gpt-6-astra, xhigh, --base origin/main) on 1a5a811: "No actionable regressions found against the supplied merge base. All 638 Telegram tests passed, along with targeted lint checks and project type checking."; 2 astra rounds (both clean; the final one ran on the current HEAD, and origin/main is still an ancestor, so nothing new needed reviewing); CodeRabbit hit its review rate limit and posted no findings, and there are no other bot comments. Merging with --admin (Protect Main requires a code-owner approval). |
Summary
Telegram
post_messagenow sends 2–10filesor 2–10attachmentsas onesendMediaGroupalbum. Before, it raised "supports a single file/attachment upload per message". One file or attachment still goes throughsend_document/send_attachment._send_document_media_group/_send_attachment_media_group, sharing_send_media_group(the same MarkdownV2 → plain caption retry as single uploads, with theFormDatarebuilt for each attempt) and_create_telegram_media_group_form_data.chat_id,message_thread_id,reply_parameters, amediaJSON string ofInputMediaitems and amedia{i}file part for each binary payload (attach://media{i}). A URL-only attachment puts its URL inmediaand gets no part. The caption andparse_modego on item 0 only. Videowidth/heightare sent when JSNumber.isIntegerwould accept them (this reuses_integral_update_id).TELEGRAM_MEDIA_GROUP_MIN = 2, existing_MAX = 10), attachment categories (file→ document,audio→ audio, image/video → visual; mixing categories raises), then no inline keyboard.NetworkError, as upstream does.ATTACHMENT_MEDIA_GROUP_TYPES.Upstream commits mapped
8d7ccdb1feat(telegram): support multiple file and attachment uploads (feat(telegram): support multiple file and attachment uploads vercel/chat#605, chat@4.34.0)d5ebec12(#833, chat@4.39.0):reply_parametersonsendMediaGroup, from the [4.41/TG4] Telegram replies: replied-to context, reply-to-bot as mention, native replies, portable file data #228 coordination note.Tests ported (
tests/test_telegram_api.py)These replace
test_rejects_multiple_attachments:rehydrate_attachmentround trip)describe("reply"))Python-only tests:
sendMediaGroup(freshFormData, plain caption, noparse_mode)attachment-{i}filename)I mutation-checked the tests: returning the first message instead of the last, putting the caption on every item, and dropping
reply_parameterseach make tests fail.Fidelity
packages/adapter-telegram/src/index.test.tsis not fidelity-mapped (#78), so the target report does not change:scripts/fidelity_target.jsonregenerated unchanged. Strict 733/733.Divergences
One divergence, in a separate
diverge(telegram):commit with a non-parity table row and a regression test. AnAttachment.typeoutsideATTACHMENT_MEDIA_GROUP_TYPESraisessend_attachment's existingValidationError("Unsupported attachment type: ...")before anyfetch_datadownload. Upstream's TS union rules this value out at compile time. In Python the dict lookup would raise a bareKeyErrorafter earlier attachments had already been downloaded.Consumer impact
Low; Telegram only. Code that relied on the old
ValidationErrorfor 2+ uploads now gets an album instead. There are newValidationErrors for more than 10 items, for a card with buttons plus 2+ uploads, and for documents or audio mixed with other types. Out of scope: none beyond #278.reply_parametersfor media groups was listed as #228's job, but #228 had already landed, so it is wired here as its coordination note asked.Validation
ruff, format, audit (0 hard failures),
--check-docs,--strict733/733, pytest 7891 passed / 24 skipped, pyrefly 0 errors.Merge gate
Independent review findings: 3 fixed, 0 declined. All three were test gaps; the code already matched upstream
sendAttachmentMediaGroup/createTelegramMediaGroupFormData. Commitfaf6a30adds tests that kill every mutation the reviewers reported (each mutation was re-run and now fails):fetch_datadownload path in an attachment album: the downloaded bytes go out asattach://media0rather than the URL, andfetch_datais awaited once. Mutations killed: skip the download; prefer the URL.[audio, image]is added to the incompatible-types parametrization. The inline-keyboard rejection now usesfetch_dataand asserts it is never awaited, which pins "rejected before any download". Mutations killed: audio counted as visual; keyboard check moved after the download.Number.isIntegerrule:1280.0becomes int1280andTrueis dropped. An emptysendMediaGroupresult raisesNetworkError. Mutations killed:if True:,width = part.width,if False:.Main merged:
origin/mainat3f06859(#304). The only conflict was CHANGELOG.md; it was resolved to one "Unreleased (4.41 wave)" heading that keeps the bullets from both sides. Fidelity is unchanged:Delta vs committed report (HEAD): missing 100 -> 100 (+0).gpt-6-astra: 1 round, on HEAD
1a5a811. Verdict: PASS. "No actionable regressions found against the supplied merge base. All 638 Telegram tests passed, along with targeted lint checks and project type checking."Bots: CodeRabbit hit its review rate limit and posted no findings. No gemini comments, and no inline review comments.
CI on
1a5a811: all green (Lint & Type Check, test 3.12/3.13, CodeQL).Local validation on
1a5a811: ruff check and format pass. The test audit has 0 hard failures.--check-docspasses and--strictis clean, with all TS tests matched. pytest: 7895 passed, 24 skipped. pyrefly: 0 errors.Closes #278
Part of #184