Skip to content

BUG: 文件传输测试发现message值为null #241

Description

@Agnes4m

确认事项

  • 我已仔细阅读并了解上述注意事项。
  • 我已使用最新版本测试过,确认问题依旧存在。
  • 我确定在 GitHub Issues 中没有相同或相似的问题。

影响版本

0.4.8

问题描述

测试v11协议中传输zip文件的处理中,当我传输文件进行测试,发现message居然是空,这意味着其实根本没有收到任何文件,导致测试出现报错。下面日志记录在alconna插件验证信息内容的时候,是为空

Image

复现步骤

使用nb创建bot终端,使用了nb官方列入文档的alconna插件,在创建一个使用alconna的响应器,在连接matcha后传入任意测试文件(附件形式)

from nonebot_plugin_alconna import on_alconna
up = on_alconna(
    "upload",
    aliases={"地图上传"},
    priority=5,
    block=True,
)

预期行为

正确解析文件,可以从event中读取到文件内容

日志信息

  + Exception Group Traceback (most recent call last):
  |   File "D:\Program Files (x86)\python\Lib\runpy.py", line 198, in _run_module_as_main
  |     return _run_code(code, main_globals, None,
  |   File "D:\Program Files (x86)\python\Lib\runpy.py", line 88, in _run_code
  |     exec(code, run_globals)
  |   File "c:\Users\ZR\.vscode\extensions\ms-python.debugpy-2025.11.2025062501-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy\__main__.py", line 71, in <module>
  |     cli.main()
  |   File "c:\Users\ZR\.vscode\extensions\ms-python.debugpy-2025.11.2025062501-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 501, in main
  |     run()
  |   File "c:\Users\ZR\.vscode\extensions\ms-python.debugpy-2025.11.2025062501-win32-x64\bundled\libs\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 351, in run_file
  |     runpy.run_path(target, run_name="__main__")
  |   File "c:\Users\ZR\.vscode\extensions\ms-python.debugpy-2025.11.2025062501-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 310, in run_path
  |     return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
  |   File "c:\Users\ZR\.vscode\extensions\ms-python.debugpy-2025.11.2025062501-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 127, in _run_module_code
  |     _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
  |   File "c:\Users\ZR\.vscode\extensions\ms-python.debugpy-2025.11.2025062501-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 118, in _run_code
  |     exec(code, run_globals)
  |   File "D:\截图\其他文件\workspace/private/test-nb2\bot.py", line 57, in <module>
  |     nonebot.run()
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\__init__.py", line 337, in run
  |     get_driver().run(*args, **kwargs)
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\drivers\fastapi.py", line 187, in run
  |     uvicorn.run(
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\uvicorn\main.py", line 580, in run
  |     server.run()
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\uvicorn\server.py", line 66, in run
  |     return asyncio.run(self.serve(sockets=sockets))
  |   File "D:\Program Files (x86)\python\Lib\asyncio\runners.py", line 195, in run
  |     return runner.run(main)
  |   File "D:\Program Files (x86)\python\Lib\asyncio\runners.py", line 118, in run
  |     return self._loop.run_until_complete(task)
  |   File "D:\Program Files (x86)\python\Lib\asyncio\base_events.py", line 678, in run_until_complete
  |     self.run_forever()
  |   File "D:\Program Files (x86)\python\Lib\asyncio\windows_events.py", line 322, in run_forever
  |     super().run_forever()
  |   File "D:\Program Files (x86)\python\Lib\asyncio\base_events.py", line 645, in run_forever
  |     self._run_once()
  |   File "D:\Program Files (x86)\python\Lib\asyncio\base_events.py", line 1999, in _run_once
  |     handle._run()
  |   File "D:\Program Files (x86)\python\Lib\asyncio\events.py", line 88, in _run
  |     self._context.run(self._callback, *self._args)
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\utils.py", line 254, in run_coro_with_shield
  |     return await coro
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\message.py", line 496, in check_and_run_matcher
  |     if not await _check_matcher(
  | > File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\message.py", line 400, in _check_matcher
  |     if not await Matcher.check_rule(bot, event, state, stack, dependency_cache):
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 405, in check_rule
  |     return event_type == (cls.type or event_type) and await cls.rule(
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\internal\rule.py", line 97, in __call__
  |     with catch({SkippedException: _handle_skipped_exception}):
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\exceptiongroup\_catch.py", line 39, in __exit__
  |     raise unhandled from exc.__cause__
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\internal\rule.py", line 98, in __call__
  |     async with anyio.create_task_group() as tg:
  |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 772, in __aexit__
  |     raise BaseExceptionGroup(
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\internal\rule.py", line 88, in _run_checker
    |     is_passed = await checker(
    |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\dependencies\__init__.py", line 113, in __call__
    |     return await cast(Callable[..., Awaitable[R]], self.call)(**values)
    |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot_plugin_alconna\rule.py", line 277, in __call__
    |     if not (msg := await selected.message_provider(event, state, bot, self.use_origin)):
    |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot_plugin_alconna\extension.py", line 164, in message_provider
    |     msg = event.get_message()
    |   File "d:\截图\其他文件\workspace\.venv\Lib\site-packages\nonebot\adapters\onebot\v11\event.py", line 51, in get_message
    |     raise ValueError("Event has no message!")
    | ValueError: Event has no message!
    +------------------------------------

额外补充

No response

参与贡献

  • 我有足够的时间和能力,愿意为此提交 PR 来修复问题。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions