1. 问题现象(必填)
使用 api.qq.query.get_group_root_files 时抛出ValidationError异常,排查后发现是返回类型GroupFileList中的GroupFileInfo.uploader、GroupFolderInfo.creator 与期望类型不匹配,值可能是int,但Model中仅声明了str
在ncatbot/types/napcat/file.py中为对应字段新增int类型的声明后可正常运作
因为改动很小,就不提pr了 :)
2. 复现步骤(必填,最好包括代码)
官方案例即可复现:
file_list = await api.qq.query.get_group_root_files(event.group_id)
for f in file_list.files or []:
print(
f" 📄 {f.file_name}"
f" (ID: {f.file_id}, 大小: {f.file_size} bytes)"
)
报错信息:
[17:35:07.084] ERROR 'ncatbot/core/registry/dispatcher.py:303' HandlerDispatcher ➜ Handler on_send_emoji 执行异常: 15 validation errors for GroupFileList
files.0.uploader
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
files.1.uploader
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
...
folders.0.creator
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
folders.1.creator
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
folders.3.creator
...
其中input_value值因为隐私被替换为123123
3. 运行环境(必填)
ubuntu:22.04
python:3.13
ncatbot:5.5.6
pydantic:2.13.4
4. 关键日志 / 截图
5. 相关配置项
6. 自查清单
1. 问题现象(必填)
使用 api.qq.query.get_group_root_files 时抛出ValidationError异常,排查后发现是返回类型GroupFileList中的GroupFileInfo.uploader、GroupFolderInfo.creator 与期望类型不匹配,值可能是int,但Model中仅声明了str
在ncatbot/types/napcat/file.py中为对应字段新增int类型的声明后可正常运作
因为改动很小,就不提pr了 :)
2. 复现步骤(必填,最好包括代码)
官方案例即可复现:
file_list = await api.qq.query.get_group_root_files(event.group_id)
for f in file_list.files or []:
print(
f" 📄 {f.file_name}"
f" (ID: {f.file_id}, 大小: {f.file_size} bytes)"
)
报错信息:
[17:35:07.084] ERROR 'ncatbot/core/registry/dispatcher.py:303' HandlerDispatcher ➜ Handler on_send_emoji 执行异常: 15 validation errors for GroupFileList
files.0.uploader
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
files.1.uploader
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
...
folders.0.creator
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
folders.1.creator
Input should be a valid string [type=string_type, input_value=123123, input_type=int]
For further information visit https://errors.pydantic.dev/2.13/v/string_type
folders.3.creator
...
其中input_value值因为隐私被替换为123123
3. 运行环境(必填)
ubuntu:22.04
python:3.13
ncatbot:5.5.6
pydantic:2.13.4
4. 关键日志 / 截图
5. 相关配置项
6. 自查清单