Repository navigation
fix(discord): upload local video replies instead of printing the file:// path - #3289
Merged
Merged
Conversation
…:// path chat_channel.py builds Reply(ReplyType.VIDEO, "file://<path>") for locally generated videos, but DiscordChannel._async_send only dispatches (VOICE, FILE), so a VIDEO reply falls through to the plain-text fallback and the user receives the raw server path while the video is never uploaded. Add ReplyType.VIDEO to that branch and cover it with a test that stubs the lazily imported discord module; VIDEO_URL keeps its existing text behaviour. Also clear the two pre-existing ruff F-class findings in this file (F541 on a placeholder-free f-string, F841 on a dead local), which the repo's changed-files lint gate would otherwise report on this PR.
Owner
|
Merged, thanks! Slack and Telegram had the same gap, so we added |
zhayujie
pushed a commit
that referenced
this pull request
Sep 29, 2026
chat_channel.py hands an agent-produced video to channels as
Reply(ReplyType.VIDEO, "file://" + path). WechatKfChannel.send dispatches
ReplyType.VIDEO_URL but never ReplyType.VIDEO, so a locally generated video
fell through to the trailing else and was only logged as
[wechat_kf] unsupported reply type: VIDEO
send() is the whole outbound contract for this channel and _send_reply() has
no per-type fallback, so the user received nothing at all -- not even the raw
file:// path the other channels used to leak before they were fixed.
The asymmetry is unique to wechat_kf: every sibling that dispatches VIDEO_URL
also dispatches VIDEO (weixin, wechatcom, wechatmp, wecom_bot, qq), and the
three channels that used to share this gap got the same one-line treatment
(#3289 discord, slack/telegram). _send_video() already exists and the video
branch already reads through _read_media(), which loads a file:// path from
disk and size-caps a genuine http(s) download, so no new plumbing is needed.
Tests: a file:// VIDEO reply is uploaded as "video" and handed to
_send_video(), and requests.get is never called for it; a remote VIDEO_URL
reply keeps its existing download-and-send behaviour.
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.
What
Add
ReplyType.VIDEOto the local-file branch ofDiscordChannel._async_send, so a video reply whose content is afile://path is uploaded throughdiscord.Fileinstead of falling through to the plain-text fallback.Fixes #3288
Why
channel/chat_channel.py:418producesReply(ReplyType.VIDEO, f"file://{url}")for locally generated videos. QQ, wechatcom, weixin and wecom_bot all matchReplyType.VIDEOin their send paths; the Discord dispatch table only lists(VOICE, FILE), so the reply reaches the finalelseand the user gets the literal server path —file:///opt/cow/tmp/clip.mp4— as a text bubble, with no video attached.ReplyType.VIDEO_URLis untouched on purpose: Discord unfurls a bare URL into a player, so posting it as text is already correct.Tests
tests/test_discord_video_reply.pystubs thediscordmodule (it is imported lazily inside_async_send) and records what the channel sends:VIDEOreply uploads the path as a file and posts no text;VIDEO_URLbehaviour so the fix cannot regress URL unfurling.On
master, the first test fails with the bug reproduced:With the patch:
The 36 failures are pre-existing: plain
masterat the same commit (c872f6f0) gives36 failed, 2178 passed, 35 skipped, 55 subtests passed in 110.69s, the same failing set (test_scheduler_timezone,test_search_files_tool,test_security_read_env_bypass, …), none of it in the Discord channel. This branch adds exactly the two passing tests above.The two extra lines in the diff
ruff (F-class gate)lints the Python files a PR changes, andchannel/discord/discord_channel.pyalready carries two findings onmaster:F541— a placeholder-free f-string at line 188;F841—receiver = str(message.channel.id)at line 280, never read afterwards (context["receiver"]is set independently at line 263, andagent_router.resolve()takes onlyexplicit_agent_id).I cleared both so the gate stays green. They are pre-existing debt in this file, unrelated to the video bug.