Skip to content

fix(feishu): fix video upload failure by using correct message type a…#1577

Closed
BlackLLII wants to merge 1 commit intosipeed:mainfrom
BlackLLII:fix/feishu-video-upload
Closed

fix(feishu): fix video upload failure by using correct message type a…#1577
BlackLLII wants to merge 1 commit intosipeed:mainfrom
BlackLLII:fix/feishu-video-upload

Conversation

@BlackLLII
Copy link
Copy Markdown

…nd metadata

Previously, video files were sent using MsgTypeFile instead of MsgTypeMedia, causing upload to succeed but message display to fail. This fix:

  • Uses MsgTypeMedia for video and MsgTypeAudio for audio messages
  • Extracts video thumbnail and duration via ffmpeg/ffprobe before upload
  • Includes image_key (thumbnail) and duration in video message content

📝 Description

Fix video file upload to Feishu failing to display properly. Previously, video files were sent using MsgTypeFile instead of
MsgTypeMedia, causing the upload to succeed but the message to display incorrectly. This PR also extracts video thumbnail and duration
metadata before upload to ensure proper rendering.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)

🔗 Related Issue

📚 Technical Context (Skip for Docs)

  • Reference URL: Feishu Open API - Send Message
  • Reasoning:
    • Video messages must use MsgTypeMedia (not MsgTypeFile) per Feishu API spec
    • MsgTypeMedia requires image_key (thumbnail) and duration fields
    • Used ffmpeg to extract thumbnail at 0.5s and ffprobe to get video duration

🧪 Test Environment

  • Hardware: Raspberry Pi 4 Model B Rev 1.4
  • OS: Debian GNU/Linux 13 (trixie) (aarch64)
  • Model/Provider: zhipu/glm-4.7
  • Channels: Feishu

📸 Evidence (Optional)

Click to view Logs/Screenshots

2026/03/14 21:15:18 [2026-03-14T13:15:18Z] [INFO] feishu: Feishu message received {sender_id=5ac85cg3, chat_id=oc_3d30ec03d888531a998b06d80d70eca5, message_id=om_x100b5461b89600a4c12c42c6959784d, preview=拍个照}
2026/03/14 21:15:18 [2026-03-14T13:15:18Z] [INFO] agent: Processing message from feishu:feishu:5ac85cg3: 拍个照 {chat_id=oc_3d30ec03d888531a998b06d80d70eca5, sender_id=feishu:5ac85cg3, session_key=, channel=feishu}
2026/03/14 21:15:18 [2026-03-14T13:15:18Z] [INFO] agent: Routed message {agent_id=main, scope_key=agent:main:feishu:direct:5ac85cg3, session_key=agent:main:feishu:direct:5ac85cg3, matched_by=default, route_agent=main, route_channel=feishu}
2026/03/14 21:15:20 [2026-03-14T13:15:20Z] [INFO] agent: LLM requested tool calls {agent_id=main, tools=[exec], count=1, iteration=1}
2026/03/14 21:15:21 [2026-03-14T13:15:21Z] [INFO] agent: Tool call: exec({"command":"libcamera-still -o /tmp/photo.jpg --width 1280 --height 720 --timeout 1 2\u003e\u00261"}) {iteration=1, agent_id=main, tool=exec}
2026/03/14 21:15:21 [2026-03-14T13:15:21Z] [INFO] tool: Tool execution started {tool=exec, args=map[command:libcamera-still -o /tmp/photo.jpg --width 1280 --height 720 --timeout 1 2>&1]}
2026/03/14 21:15:21 [2026-03-14T13:15:21Z] [ERROR] tool: Tool execution failed {tool=exec, duration=4, error=sh: 1: libcamera-still: not found

Exit code: exit status 127}
2026/03/14 21:15:22 [2026-03-14T13:15:22Z] [INFO] agent: LLM requested tool calls {tools=[exec], count=1, iteration=2, agent_id=main}
2026/03/14 21:15:23 [2026-03-14T13:15:23Z] [INFO] agent: Tool call: exec({"command":"fswebcam -r 1280x720 --no-banner /tmp/photo.jpg 2\u003e\u00261"}) {agent_id=main, tool=exec, iteration=2}
2026/03/14 21:15:23 [2026-03-14T13:15:23Z] [INFO] tool: Tool execution started {tool=exec, args=map[command:fswebcam -r 1280x720 --no-banner /tmp/photo.jpg 2>&1]}
2026/03/14 21:15:23 [2026-03-14T13:15:23Z] [ERROR] tool: Tool execution failed {tool=exec, duration=2, error=sh: 1: fswebcam: not found

Exit code: exit status 127}
2026/03/14 21:15:24 [2026-03-14T13:15:24Z] [INFO] agent: LLM requested tool calls {iteration=3, agent_id=main, tools=[exec], count=1}
2026/03/14 21:15:24 [2026-03-14T13:15:24Z] [INFO] agent: Tool call: exec({"command":"ffmpeg -f v4l2 -i /dev/video0 -frames:v 1 -y /tmp/photo.jpg 2\u003e\u00261 | head -20"}) {agent_id=main, tool=exec, iteration=3}
2026/03/14 21:15:24 [2026-03-14T13:15:24Z] [INFO] tool: Tool execution started {tool=exec, args=map[command:ffmpeg -f v4l2 -i /dev/video0 -frames:v 1 -y /tmp/photo.jpg 2>&1 | head -20]}
2026/03/14 21:15:31 [2026-03-14T13:15:31Z] [INFO] tool: Tool execution completed {duration_ms=7528, result_length=2431, tool=exec}
2026/03/14 21:15:43 [2026-03-14T13:15:43Z] [INFO] agent: LLM requested tool calls {agent_id=main, tools=[exec], count=1, iteration=4}
2026/03/14 21:15:43 [2026-03-14T13:15:43Z] [INFO] agent: Tool call: exec({"command":"ls -lh /tmp/photo.jpg \u0026\u0026 file /tmp/photo.jpg"}) {agent_id=main, tool=exec, iteration=4}
2026/03/14 21:15:43 [2026-03-14T13:15:43Z] [INFO] tool: Tool execution started {tool=exec, args=map[command:ls -lh /tmp/photo.jpg && file /tmp/photo.jpg]}
2026/03/14 21:15:44 [2026-03-14T13:15:44Z] [INFO] tool: Tool execution completed {tool=exec, duration_ms=215, result_length=147}
2026/03/14 21:15:45 [2026-03-14T13:15:45Z] [INFO] agent: LLM requested tool calls {iteration=5, agent_id=main, tools=[send_file], count=1}
2026/03/14 21:15:45 [2026-03-14T13:15:45Z] [INFO] agent: Tool call: send_file({"path":"/tmp/photo.jpg"}) {agent_id=main, tool=send_file, iteration=5}
2026/03/14 21:15:45 [2026-03-14T13:15:45Z] [INFO] tool: Tool execution started {tool=send_file, args=map[path:/tmp/photo.jpg]}
2026/03/14 21:15:45 [2026-03-14T13:15:45Z] [INFO] tool: Tool execution completed {tool=send_file, duration_ms=0, result_length=29}
2026/03/14 21:15:47 [2026-03-14T13:15:47Z] [INFO] agent: LLM response without tool calls (direct answer) {agent_id=main, iteration=6, content_chars=236}
2026/03/14 21:15:47 [2026-03-14T13:15:47Z] [INFO] agent: Response: 📸 照片已拍摄并发送!

  • 分辨率: 640x480
  • 格式: JPEG (19KB)
  • 设备: /dev/video0 (USB 摄像头)

这次成功绕过了之前的权限限制。需要我调整拍摄参数(如分辨率)... {agent_id=main, session_key=agent:main:feishu:direct:5ac85cg3, iterations=6, final_length=236}
2026/03/14 21:15:47 [2026-03-14T13:15:47Z] [INFO] agent: Published outbound response {channel=feishu, chat_id=oc_3d30ec03d888531a998b06d80d70eca5, content_len=236}

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

…nd metadata

Previously, video files were sent using MsgTypeFile instead of MsgTypeMedia,
causing upload to succeed but message display to fail. This fix:
- Uses MsgTypeMedia for video and MsgTypeAudio for audio messages
- Extracts video thumbnail and duration via ffmpeg/ffprobe before upload
- Includes image_key (thumbnail) and duration in video message content
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 14, 2026

CLA assistant check
All committers have signed the CLA.

@BlackLLII
Copy link
Copy Markdown
Author

BlackLLII commented Mar 15, 2026

Correction: the log I pasted in the description above was wrong. Here is the correct log:

08:41:37 INF feishu feishu_64.go:420 (feishu.(*FeishuChannel).handleMessageReceive) > Feishu message received chat_id=oc_3d30ec03d888531a998b06d80d70eca5 message_id=om_x100b54544ac724a4c39e723d6f0be0c preview="录个10秒视频给我" sender_id=5ac85cg3
08:41:37 INF agent  loop.go:683 (agent.(*AgentLoop).processMessage) > Processing message from feishu:feishu:5ac85cg3: 录个10秒视频给我 channel=feishu chat_id=oc_3d30ec03d888531a998b06d80d70eca5 sender_id=feishu:5ac85cg3 session_key=
08:41:37 INF agent  loop.go:724 (agent.(*AgentLoop).processMessage) > Routed message agent_id=main matched_by=default route_agent=main route_channel=feishu scope_key=agent:main:feishu:direct:5ac85cg3 session_key=agent:main:feishu:direct:5ac85cg3
08:41:39 INF agent  loop.go:1213 (agent.(*AgentLoop).runLLMIteration) > LLM requested tool calls agent_id=main count=1 iteration=1 tools=["exec"]
08:41:39 INF agent  loop.go:1272 (agent.(*AgentLoop).runLLMIteration.func2) > Tool call: exec({"command":"ls -la /dev/video*"}) agent_id=main iteration=1 tool=exec
08:41:39 INF tool   registry.go:168 (tools.(*ToolRegistry).ExecuteWithContext) > Tool execution started args={"command":"ls -la /dev/video*"} tool=exec
08:41:39 INF tool   registry.go:217 (tools.(*ToolRegistry).ExecuteWithContext) > Tool execution completed duration_ms=12 result_length=990 tool=exec
08:41:41 INF agent  loop.go:1213 (agent.(*AgentLoop).runLLMIteration) > LLM requested tool calls agent_id=main count=1 iteration=2 tools=["exec"]
08:41:41 INF agent  loop.go:1272 (agent.(*AgentLoop).runLLMIteration.func2) > Tool call: exec({"command":"ffmpeg -t 10 -f v4l2 -framerate 30 -video_size 640x480 -i /dev/video0 -c:v libx264 -pix_fmt yuv420p /home/tiancheng/.picoclaw/workspace/video_10s.mp4"}) agent_id=main iteration=2 tool=exec
08:41:41 INF tool   registry.go:168 (tools.(*ToolRegistry).ExecuteWithContext) > Tool execution started args={"command":"ffmpeg -t 10 -f v4l2 -framerate 30 -video_size 640x480 -i /dev/video0 -c:v libx264 -pix_fmt yuv420p /home/tiancheng/.picoclaw/workspace/video_10s.mp4"} tool=exec
08:41:54 INF tool   registry.go:217 (tools.(*ToolRegistry).ExecuteWithContext) > Tool execution completed duration_ms=12594 result_length=6783 tool=exec
08:41:55 INF agent  loop.go:1213 (agent.(*AgentLoop).runLLMIteration) > LLM requested tool calls agent_id=main count=1 iteration=3 tools=["send_file"]
08:41:55 INF agent  loop.go:1272 (agent.(*AgentLoop).runLLMIteration.func2) > Tool call: send_file({"path":"/home/tiancheng/.picoclaw/workspace/video_10s.mp4"}) agent_id=main iteration=3 tool=send_file
08:41:55 INF tool   registry.go:168 (tools.(*ToolRegistry).ExecuteWithContext) > Tool execution started args={"path":"/home/tiancheng/.picoclaw/workspace/video_10s.mp4"} tool=send_file
08:41:55 INF tool   registry.go:217 (tools.(*ToolRegistry).ExecuteWithContext) > Tool execution completed duration_ms=0 result_length=33 tool=send_file
08:41:56 ERR feishu feishu_64.go:323 (feishu.(*FeishuChannel).sendMediaPart) > Failed to send media error="feishu file send api error (code=230055 msg=The type of file upload does not match the type of message being sent.)" type=video
08:41:57 INF agent  loop.go:1194 (agent.(*AgentLoop).runLLMIteration) > LLM response without tool calls (direct answer) agent_id=main content_chars=143 iteration=4
08:41:57 INF agent  loop.go:926 (agent.(*AgentLoop).runAgentLoop) > Response: 视频已发送!🎬 ... agent_id=main final_length=143 iterations=4 session_key=agent:main:feishu:direct:5ac85cg3
08:41:57 INF agent  loop.go:300 (agent.(*AgentLoop).Run.func1) > Published outbound response channel=feishu chat_id=oc_3d30ec03d888531a998b06d80d70eca5 content_len=143
08:41:57 ERR feishu feishu_64.go:323 (feishu.(*FeishuChannel).sendMediaPart) > Failed to send media error="feishu file send api error (code=230055 msg=The type of file upload does not match the type of message being sent.)" type=video
08:41:59 ERR feishu feishu_64.go:323 (feishu.(*FeishuChannel).sendMediaPart) > Failed to send media error="feishu file send api error (code=230055 msg=The type of file upload does not match the type of message being sent.)" type=video
08:42:02 ERR feishu feishu_64.go:323 (feishu.(*FeishuChannel).sendMediaPart) > Failed to send media error="feishu file send api error (code=230055 msg=The type of file upload does not match the type of message being sent.)" type=video
08:42:02 ERR channels manager.go:739 (channels.(*Manager).sendMediaWithRetry) > SendMedia failed error="feishu send media: temporary failure" channel=feishu chat_id=oc_3d30ec03d888531a998b06d80d70eca5 retries=3

The key error: send_file used the wrong upload type for video. Feishu API returned code=230055 — the file upload type does not match the message type being sent.

@sipeed-bot
Copy link
Copy Markdown

sipeed-bot bot commented Mar 31, 2026

@BlackLLII Hi! This PR has had no activity for over 2 weeks, so I'm closing it for now to keep things tidy. If it's still relevant, feel free to reopen it anytime and we'll pick it back up.

@sipeed-bot sipeed-bot bot closed this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: channel go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants