Repository navigation
fix(wechatmp): upload a local video reply instead of crashing on its path - #3321
Merged
Merged
Conversation
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.
Owner
|
Merged, thanks @Lesereingrape! Resolving the |
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.
Fixes #3320
ReplyType.VIDEOcontent is a path:channel/chat_channel.py:419buildsReply(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:245passive,:369active) hitvideo_storage.seek(0)on astrand raisedAttributeErrorbefore theupload — and before the
try, so nothing local caught it.ChatChannel._sendretried twice with its3 + 3 * retry_cntsleeps and thenswallowed it, so the user got the text answer without the video.
Remote video was unaffected because
ReplyType.VIDEO_URLgoes through_download_remote_media, which returns aBytesIO. Only locally producedvideos were dropped, which is exactly the case the agent generates.
The fix mirrors the
ReplyType.IMAGE_URLbranch of the same method(
:189-194): resolve afile://or plain path into aBytesIO, pass analready open stream through untouched.
Test:
test_wechatmp_uploads_a_local_video, parametrized over the passiveand active mode, asserts the upload receives the file's bytes and that the
media actually reaches the user. Red on current master:
Full suite before and after is identical apart from the two new tests, and the
sorted
FAILEDlist diffs empty.ruff --select Fclean.