What happened / 发生了什么
在使用 NapCat + AstrBot(aiocqhttp / OneBot v11 适配器)时,QQ 用户发送视频消息后,AstrBot 会报错:
[Core][ERRO][v4.24.2] [core.astr_main_agent:655]: Error processing video attachment: not a valid file: 8df7673a71f8540186c33f047b806c57.mp4
日志显示 AstrBot 在处理视频附件时,拿到的是一个类似 8df7673a71f8540186c33f047b806c57.mp4 的文件名,但这并不是容器内真实存在的可访问视频路径,因此 convert_to_file_path() 失败。
Reproduce / 如何复现?
- 使用 NapCat 和 AstrBot,二者部署在同一台服务器的不同 Docker 容器中
- AstrBot 使用
aiocqhttp 适配器接收 QQ 消息
- QQ 用户向机器人发送一个视频消息
- AstrBot 日志中出现:
Error processing video attachment: not a valid file: xxx.mp4
AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
- 1Panel
- Docker Compose
- NapCat 和 AstrBot 在不同容器中
- 已确认共享挂载已配置
AstrBot 容器挂载了:
/opt/1panel/apps/Astrbot/ntqq -> /app/.config/QQ
/opt/1panel/apps/Astrbot/data -> /AstrBot/data
NapCat 容器也挂载了相同的 ntqq 目录。
AstrBot 版本
协议端 / 平台
- NapCat
- aiocqhttp / OneBot v11
- QQ 私聊 / 群聊均可复现(我这里是在个人 QQ 场景下复现)
OS
Windows
Logs / 报错日志
实际排查结果
我已经做过以下排查:
1. 共享挂载没有问题
NapCat 和 AstrBot 都挂载了同一个宿主机目录到 /app/.config/QQ。
2. NapCat 容器里确实存在视频缓存文件
在 NapCat 容器中执行:
find / -name "*.mp4" 2>/dev/null | head -50
可以找到真实视频文件,例如:
/app/.config/QQ/nt_qq_253aed7e0b8a3e5ea712a7ff1a9d2b39/nt_data/Video/2026-04/Ori/32300fb4b6d5801d2d48c0ae99d50a4c.mp4
3. 但是 AstrBot 报错里拿到的并不是这个真实路径
AstrBot 报错里拿到的是:
8df7673a71f8540186c33f047b806c57.mp4
这个值:
- 不是
file:///...
- 不是
http(s)://...
- 不是容器内真实存在的绝对路径
- 甚至和 NapCat 实际缓存文件名也不一致
4. 代码层面定位结果
在 astrbot/core/message/components.py 中:
class Video(BaseMessageComponent):
async def convert_to_file_path(self) -> str:
url = self.file
if url and url.startswith("file:///"):
return url[8:]
if url and url.startswith("http"):
...
if os.path.exists(url):
return os.path.abspath(url)
raise Exception(f"not a valid file: {url}")
这里 Video.convert_to_file_path() 只支持:
file:///...
http(s)://...
- 本地存在的路径
因此当 self.file == "8df7673a71f8540186c33f047b806c57.mp4" 时,会必然抛出:
not a valid file: 8df7673a71f8540186c33f047b806c57.mp4
5. aiocqhttp 适配器中,file 类型已有 NapCat 特殊处理,但 video 没有
在 astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py 中:
file 类型会单独处理,并调用 NapCat API 获取真实 URL
- 但
video 类型没有单独分支,而是走了兜底逻辑:
a = ComponentTypes[t](**m["data"])
abm.message.append(a)
这意味着 video 段最终大概率被直接构造成了:
Video(file="8df7673a71f8540186c33f047b806c57.mp4")
随后在 astr_main_agent.py 中调用 video.convert_to_file_path() 时失败。
我怀疑的问题点
怀疑是 aiocqhttp 适配器对 NapCat 的 video 消息段没有做专门兼容:
file 类型已有 NapCat 特殊处理
video 类型缺少类似处理
- 导致 OneBot / NapCat 提供的
video.data.file 被直接当成本地文件路径使用
建议的修复方向
可能的修复方向:
- 在
aiocqhttp_platform_adapter.py 中为 video 增加专门分支,不走通用兜底
- 如果 NapCat 原始
video 段中存在可用 URL / path / file_id,则转换为 AstrBot 可识别的 Video(file=...)
- 如果需要,可仿照
file 类型调用 NapCat API 获取可访问地址
- 或者至少在
video 无法解析时不要把无效 file 直接传入 Video
相关代码位置
astrbot/core/message/components.py
astrbot/core/astr_main_agent.py
astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py
附加日志
[2026-05-06 15:42:49.642] [Core][INFO][core.event_bus:61]: [default] [个人QQ(aiocqhttp)] Sense/307062828: [ComponentType.Video]
[2026-05-06 15:42:49.652] [Core][ERRO][v4.24.2] [core.astr_main_agent:655]: Error processing video attachment: not a valid file: 8df7673a71f8540186c33f047b806c57.mp4
Are you willing to submit a PR? / 你愿意提交 PR 吗?
Code of Conduct
What happened / 发生了什么
在使用 NapCat + AstrBot(aiocqhttp / OneBot v11 适配器)时,QQ 用户发送视频消息后,AstrBot 会报错:
日志显示 AstrBot 在处理视频附件时,拿到的是一个类似
8df7673a71f8540186c33f047b806c57.mp4的文件名,但这并不是容器内真实存在的可访问视频路径,因此convert_to_file_path()失败。Reproduce / 如何复现?
aiocqhttp适配器接收 QQ 消息AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
AstrBot 容器挂载了:
NapCat 容器也挂载了相同的
ntqq目录。AstrBot 版本
协议端 / 平台
OS
Windows
Logs / 报错日志
实际排查结果
我已经做过以下排查:
1. 共享挂载没有问题
NapCat 和 AstrBot 都挂载了同一个宿主机目录到
/app/.config/QQ。2. NapCat 容器里确实存在视频缓存文件
在 NapCat 容器中执行:
可以找到真实视频文件,例如:
3. 但是 AstrBot 报错里拿到的并不是这个真实路径
AstrBot 报错里拿到的是:
这个值:
file:///...http(s)://...4. 代码层面定位结果
在
astrbot/core/message/components.py中:这里
Video.convert_to_file_path()只支持:file:///...http(s)://...因此当
self.file == "8df7673a71f8540186c33f047b806c57.mp4"时,会必然抛出:5. aiocqhttp 适配器中,
file类型已有 NapCat 特殊处理,但video没有在
astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py中:file类型会单独处理,并调用 NapCat API 获取真实 URLvideo类型没有单独分支,而是走了兜底逻辑:这意味着
video段最终大概率被直接构造成了:随后在
astr_main_agent.py中调用video.convert_to_file_path()时失败。我怀疑的问题点
怀疑是
aiocqhttp适配器对 NapCat 的video消息段没有做专门兼容:file类型已有 NapCat 特殊处理video类型缺少类似处理video.data.file被直接当成本地文件路径使用建议的修复方向
可能的修复方向:
aiocqhttp_platform_adapter.py中为video增加专门分支,不走通用兜底video段中存在可用 URL / path / file_id,则转换为 AstrBot 可识别的Video(file=...)file类型调用 NapCat API 获取可访问地址video无法解析时不要把无效file直接传入Video相关代码位置
astrbot/core/message/components.pyastrbot/core/astr_main_agent.pyastrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py附加日志
Are you willing to submit a PR? / 你愿意提交 PR 吗?
Code of Conduct