fix(adapter-telegram): handle video_note (round video messages) in extractAttachments#457
Merged
Merged
Conversation
Contributor
|
@xbeastx is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
dancer
approved these changes
May 11, 2026
Round video messages (video_note) were silently dropped because extractAttachments had no branch for them. Adds the video_note field to TelegramMessage and extracts it as a "video" attachment with width/height set to the clip's length. Fixes vercel#456
4f51e12 to
ce3cd6a
Compare
This was referenced May 29, 2026
patrick-chinchill
added a commit
to Chinchill-AI/chat-sdk-python
that referenced
this pull request
May 30, 2026
…cel/chat#457, #485) (#119) * feat(telegram): video_note extraction + typed attachment uploads (vercel/chat#457, #485) Port two upstream Telegram adapter changes from chat@4.29.0: - vercel/chat#457 (711babe): extract video_note (round video messages) in extract_attachments. Round videos arrive in the distinct video_note field and were silently dropped; they now extract as a "video" attachment with width/height set to the clip's length. - vercel/chat#485 (add2730): typed outgoing attachment uploads. Adds extract_postable_attachments to shared adapter utils and a send_attachment path that selects the correct Bot API method per attachment type (sendPhoto/sendAudio/sendVideo/sendDocument) via the ATTACHMENT_UPLOADS mapping. Supports binary (data/fetch_data) multipart uploads and URL-only attachments, with single-attachment and no-mixing-with-files validation matching upstream. Tracking #98. https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj * fix(shared): use explicit None checks in extract_postable_attachments (coderabbit) CLAUDE.md lists `x or default` → `x if x is not None else default` as a project porting rule (truthiness trap). The two truthiness checks in the new `extract_postable_attachments` violate that rule. Convert both to explicit `is not None` comparisons; behavior is unchanged for the typed input contract, but the rule is now honored. Scope discipline: leaving the sibling `extract_files` for a separate cleanup PR — it pre-dates this work and changing it here would muddy the diff. https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj * fix(telegram): use is-not-None fallbacks in send_attachment (audit) * fix(telegram): guard unsupported attachment type with ValidationError (coderabbit) Addresses CodeRabbit's CHANGES_REQUESTED on #119. `ATTACHMENT_UPLOADS[attachment.type]` raised a bare `KeyError` for any `attachment.type` outside the supported set. `Attachment.type` is a `Literal`, but Python does not enforce Literals at runtime, so an untyped/dynamic caller can supply an out-of-set value. Guard the lookup and raise a `ValidationError` naming the bad type and the supported set, consistent with the other validation paths in `send_attachment`. New `test_rejects_unsupported_attachment_type` is load-bearing — reverting the guard makes the call raise `KeyError` (not `ValidationError`) and the test fails. https://claude.ai/code/session_01FyMxQn2BEAzmwKS1GZczKj --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #456
Telegram's round video clips (
video_note) were silently dropped byextractAttachments— the function had no branch for them, so messages sent as circular videos produced an empty attachment list with no text.Changes
packages/adapter-telegram/src/types.tsvideo_notefield toTelegramMessageinterfacepackages/adapter-telegram/src/index.tsvideo_notehandling inextractAttachments, extracted as a"video"attachment withwidth/heightset to the clip'slength(round videos always have equal dimensions)Telegram Bot API reference
video_note—lengthis both width and height; nomime_typeorfile_name.Test plan
videoattachment with non-nullwidth/height