问题描述
当 MoviePilot Agent 在飞书对话回复中使用 Markdown 图片语法(如 )时,飞书流式卡片更新会失败,报错:
飞书流式卡片内容更新失败:card_id=xxx, element_id=mp_stream_body, sequence=7, code=200570, msg=ErrMsg: card contains invalid image keys; ErrorValue: image key https://image.tmdb.org/t/p/original/xxx.jpg
复现步骤
- 配置飞书通知渠道,启用 Agent 对话功能
- 向 Agent 发送搜索请求(如搜索电影)
- Agent 回复中包含 TMDB 海报图片的 Markdown 语法
- 飞书流式卡片更新失败
问题原因
飞书卡片 API 不支持直接使用外部 URL 作为图片 key。Agent 回复中的 Markdown 图片语法  被飞书解析为图片 key,但外部 URL 不是有效的飞书 image key。
临时解决方案
在 app/modules/feishu/feishu.py 的 _escape_card_text 方法中,添加正则表达式移除 Markdown 图片语法:
@staticmethod
def _escape_card_text(text: Optional[str]) -> str:
"""转义飞书卡片 markdown 中易误触的字符,同时移除外部图片语法。"""
if not text:
return ""
escaped = str(text)
import re as _re
escaped = _re.sub(r"!\[[^\]]*\]\([^)]*\)", "", escaped)
for source, target in {
"\\": "\",
"<": "<",
">": ">",
}.items():
escaped = escaped.replace(source, target)
return escaped
建议修复
- 在
_escape_card_text 方法中自动过滤外部图片语法
- 或者在 Agent 回复逻辑中,避免直接使用 Markdown 图片语法,改用飞书的图片上传接口
环境信息
- MoviePilot 版本:v2 (latest)
- 部署方式:Docker
- 飞书模块:
app/modules/feishu/feishu.py
问题描述
当 MoviePilot Agent 在飞书对话回复中使用 Markdown 图片语法(如
)时,飞书流式卡片更新会失败,报错:复现步骤
问题原因
飞书卡片 API 不支持直接使用外部 URL 作为图片 key。Agent 回复中的 Markdown 图片语法
被飞书解析为图片 key,但外部 URL 不是有效的飞书 image key。临时解决方案
在
app/modules/feishu/feishu.py的_escape_card_text方法中,添加正则表达式移除 Markdown 图片语法:建议修复
_escape_card_text方法中自动过滤外部图片语法环境信息
app/modules/feishu/feishu.py