Skip to content

fix(adapter-telegram): handle video_note (round video messages) in extractAttachments#457

Merged
dancer merged 2 commits into
vercel:mainfrom
xbeastx:fix/telegram-video-note
May 11, 2026
Merged

fix(adapter-telegram): handle video_note (round video messages) in extractAttachments#457
dancer merged 2 commits into
vercel:mainfrom
xbeastx:fix/telegram-video-note

Conversation

@xbeastx
Copy link
Copy Markdown
Contributor

@xbeastx xbeastx commented May 7, 2026

Summary

Closes #456

Telegram's round video clips (video_note) were silently dropped by extractAttachments — 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.ts

  • Added video_note field to TelegramMessage interface

packages/adapter-telegram/src/index.ts

  • Added video_note handling in extractAttachments, extracted as a "video" attachment with width/height set to the clip's length (round videos always have equal dimensions)

Telegram Bot API reference

video_notelength is both width and height; no mime_type or file_name.

Test plan

  • Send a round video in Telegram to a bot using this adapter and verify the message has a video attachment with non-null width/height
  • Verify existing attachment types (photo, video, audio, voice, document) are unaffected

@xbeastx xbeastx requested a review from a team as a code owner May 7, 2026 07:53
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

@xbeastx is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

xbeastx added 2 commits May 11, 2026 17:10
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
@dancer dancer force-pushed the fix/telegram-video-note branch from 4f51e12 to ce3cd6a Compare May 11, 2026 16:14
@dancer dancer assigned xbeastx and unassigned dancer May 11, 2026
@dancer dancer merged commit 711babe into vercel:main May 11, 2026
9 of 11 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[adapter-telegram] video_note (round video messages) not handled in extractAttachments

2 participants