Skip to content

fix(wechatmp): upload a local video reply instead of crashing on its path - #3321

Merged
zhayujie merged 1 commit into
zhayujie:masterfrom
Lesereingrape:fix/wechatmp-local-video
Sep 29, 2026
Merged

zhayujie merged 1 commit into
zhayujie:masterfrom
Lesereingrape:fix/wechatmp-local-video

Conversation

@Lesereingrape

Copy link
Copy Markdown
Contributor

Fixes #3320

ReplyType.VIDEO content is a path: channel/chat_channel.py:419 builds
Reply(ReplyType.VIDEO, f"file://" + path), and dingtalk, feishu, telegram,
wechatcom, wechat_kf and wecom_bot all read it as one. wechatmp read it as an
already open handle, so both of its VIDEO branches
(wechatmp_channel.py:245 passive, :369 active) hit
video_storage.seek(0) on a str and raised AttributeError before the
upload — and before the try, so nothing local caught it.
ChatChannel._send retried twice with its 3 + 3 * retry_cnt sleeps and then
swallowed it, so the user got the text answer without the video.

Remote video was unaffected because ReplyType.VIDEO_URL goes through
_download_remote_media, which returns a BytesIO. Only locally produced
videos were dropped, which is exactly the case the agent generates.

The fix mirrors the ReplyType.IMAGE_URL branch of the same method
(:189-194): resolve a file:// or plain path into a BytesIO, pass an
already open stream through untouched.

Test: test_wechatmp_uploads_a_local_video, parametrized over the passive
and active mode, asserts the upload receives the file's bytes and that the
media actually reaches the user. Red on current master:

AttributeError: 'str' object has no attribute 'seek'
2 failed, 6 passed

Full suite before and after is identical apart from the two new tests, and the
sorted FAILED list diffs empty. ruff --select F clean.

ChatChannel produces Reply(ReplyType.VIDEO, "file://" + path) and every other
channel reads that content as a path. Both wechatmp VIDEO branches called
.seek on the string, so the upload never ran, _send retried twice and dropped
the reply, and the user got the text answer without the video.
@zhayujie
zhayujie merged commit c7ce0e7 into zhayujie:master Sep 29, 2026
3 checks passed
@zhayujie

Copy link
Copy Markdown
Owner

Merged, thanks @Lesereingrape! Resolving the file:// payload into a stream the same way the image branch does covers both passive and active modes, so wechatmp now joins the other channels in uploading locally generated videos. This will ship in v2.2.0.

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.

wechatmp silently drops a locally produced video: ReplyType.VIDEO content is a path, the branch calls .seek on it

2 participants