nonebot / adapter-feishu

NoneBot2 飞书适配器 / FeiShu (LarkSuite) adapter for nonebot2
https://feishu.adapters.nonebot.dev
MIT License
30 stars 7 forks source link

Bug: 群聊中回复机器人时,控制台报错 ValidationError: 1 validation error for ReplyResponse #107

Open fkxxyz opened 5 months ago

fkxxyz commented 5 months ago

操作系统

Windows

Python 版本

3.12.3

NoneBot 版本

2.3.1

飞书适配器版本

2.6.1

描述问题

群聊中,点右键机器人的条消息,回复机器人时,控制台报错

06-26 23:11:39 [ERROR] nonebot | FEISHU | Failed to get reply message
Traceback (most recent call last):
  File "D:\Program Files\JetBrains\PyCharm Community Edition 2024.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 2247, in <module>
    main()
  File "D:\Program Files\JetBrains\PyCharm Community Edition 2024.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 2229, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\Program Files\JetBrains\PyCharm Community Edition 2024.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1539, in run
    return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
  File "D:\Program Files\JetBrains\PyCharm Community Edition 2024.1.2\plugins\python-ce\helpers\pydev\pydevd.py", line 1546, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\Program Files\JetBrains\PyCharm Community Edition 2024.1.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:\User\fkxxyz\pro\cclover\bot.py", line 17, in <module>
    nonebot.run()
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\nonebot\__init__.py", line 335, in run
    get_driver().run(*args, **kwargs)
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\nonebot\drivers\fastapi.py", line 186, in run
    uvicorn.run(
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\uvicorn\main.py", line 577, in run
    server.run()
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\uvicorn\server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\asyncio\base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\asyncio\windows_events.py", line 322, in run_forever
    super().run_forever()
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\asyncio\base_events.py", line 641, in run_forever
    self._run_once()
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\asyncio\base_events.py", line 1987, in _run_once
    handle._run()
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\nonebot\adapters\feishu\bot.py", line 399, in handle_event
    await _check_reply(self, event)
> File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\nonebot\adapters\feishu\bot.py", line 35, in _check_reply
    result = type_validate_python(
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\nonebot\compat.py", line 212, in type_validate_python
    return TypeAdapter(type_).validate_python(data)
  File "D:\.pyenv\pyenv-win\versions\3.12.3\Lib\site-packages\pydantic\type_adapter.py", line 260, in validate_python
    return self.validator.validate_python(object, strict=strict, from_attributes=from_attributes, context=context)
pydantic_core._pydantic_core.ValidationError: 1 validation error for ReplyResponse
data.items.0.mentions
  Field required [type=missing, input_value={'body': {'content': '{"t...7640', 'updated': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.7/v/missing

而后 MessageEvent 事件里的 event.reply 是 None

复现步骤

  1. 飞书群聊中,机器人发过消息。
  2. 右键点击机器人发的这条消息,点击“回复”,然后输入任意文字发送。

期望的结果

控制台不报错,且 MessageEvent 事件里的 event.reply 不为 None

截图或日志

飞书那边确实没有 ReplyResponse 里所需的 mentions 字段。

image

StarHeartHunt commented 5 months ago

试试 https://github.com/nonebot/adapter-feishu/releases/tag/v2.6.2