GraiaProject / Application

一个设计精巧, 协议实现完备的, 基于 mirai-api-http 的即时聊天软件自动化框架.
https://graia-document.vercel.app/
GNU Affero General Public License v3.0
438 stars 63 forks source link

Bug report:收到xml消息后会意外退出 #23

Closed chenshenwei1998 closed 4 years ago

chenshenwei1998 commented 4 years ago

描述你遇到的问题: 在收到xml信息时客户端抛出错误并shut down

复现步骤: 该 BUG 会在进行以下操作后出现: 当接收到xml消息时会发生错误, 我的测试情景: 其他用户(或是其他机器人)给我方bot(私聊)发送一条基于xml的歌曲卡片信息,这时候graia-application就会shut down(这个情况平时基本遇不到,我是在看酷Q发送的歌曲卡片信息时意外发现的)

控制台日志输出截图:

mirai-console信息如下: [mirai:service:2,<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="2" templateID="1" action="web" brief="[分享] Butter-Fly" sourceMsgId="0" url="https://i.y.qq.com/v8/playsong.html?_wv=1&amp;songid=103178393&amp;souce=qqshare&amp;source=qqshare&amp;ADTAG=qqshare" flag="0" adverSign="0" multiMsgFlag="0"><item layout="2"><audio cover="http://imgcache.qq.com/music/photo/album_500/41/500_albumpic_1066541_0.jpg" src="http://apd-vlive.apdcdn.tc.qq.com/amobile.music.tc.qq.com/C400003XJxM604j9In.m4a?guid=667547133&amp;vkey=4BFF71E737EA556F0A35D94E93B83426F34A22417C3733FBC1B6C08337D4415138209B740FBF5EAF2BBA68D3CC824B6F06C94416FEA20CBC&amp;uin=0&amp;fromtag=38" /><title>Butter-Fly</title><summary>和田光司</summary></item><source name="QQ音乐" icon="https://i.gtimg.cn/open/app_icon/01/07/98/56/1101079856_100_m.png?date=20200807" url="http://web.p.qq.com/qqmpmobile/aio/app.html?id=1101079856" action="app" a_actionData="com.tencent.qqmusic" i_actionData="tencent1101079856://" appid="1101079856" /></msg>]https://i.y.qq.com/v8/playsong.html?_wv=1&songid=103178393&souce=qqaio&ADTAG=aiodiange

graia-application错误信息如下:

[2020-08-07 18:21:53,473][INFO]: application shutdowning...
[2020-08-07 18:21:53,475][INFO]: goodbye :)
Traceback (most recent call last):
  File "bot.py", line 149, in <module>
    app.launch_blocking()
  File "D:\software\anaconda3\lib\site-packages\graia\application\__init__.py", line 580, in launch_blocking
    loop.run_until_complete(fetch_method)
  File "D:\software\anaconda3\lib\asyncio\base_events.py", line 583, in run_until_complete
    return future.result()
  File "D:\software\anaconda3\lib\site-packages\graia\application\__init__.py", line 523, in ws_all_poster
    event = await self.auto_parse_by_type(received_data)
  File "D:\software\anaconda3\lib\site-packages\graia\application\__init__.py", line 507, in auto_parse_by_type
    k: v for k, v in original_dict.items() if k != "type"
  File "pydantic\main.py", line 455, in pydantic.main.BaseModel.parse_obj
  File "D:\software\anaconda3\lib\site-packages\graia\broadcast\entities\event.py", line 31, in __init__
    super().__init__(**kwargs)
  File "pydantic\main.py", line 344, in pydantic.main.BaseModel.__init__
  File "pydantic\main.py", line 900, in pydantic.main.validate_model
  File "pydantic\fields.py", line 570, in pydantic.fields.ModelField.validate
  File "pydantic\fields.py", line 725, in pydantic.fields.ModelField._validate_singleton
  File "pydantic\fields.py", line 732, in pydantic.fields.ModelField._apply_validators
  File "pydantic\class_validators.py", line 311, in pydantic.class_validators._generic_validator_basic.lambda12
  File "pydantic\main.py", line 587, in pydantic.main.BaseModel.validate
  File "D:\software\anaconda3\lib\site-packages\graia\application\message\chain.py", line 38, in parse_obj
    handled_elements.append(iii.fromExternal(ii.parse_obj(i)))
  File "pydantic\main.py", line 455, in pydantic.main.BaseModel.parse_obj
  File "pydantic\main.py", line 344, in pydantic.main.BaseModel.__init__
  File "pydantic\main.py", line 874, in pydantic.main.validate_model
pydantic.errors.ConfigError: field "type" not yet prepared so type is still a ForwardRef, you might need to call Xml.update_forward_refs().

运行环境:

GreyElaina commented 4 years ago

行吧, 我知道了, 0.1.5修掉

GreyElaina commented 4 years ago

image 你改改这行就好了.

GreyElaina commented 4 years ago

刚才0.1.4修的时候失智了, 然后bug+=1

chenshenwei1998 commented 4 years ago

刚才0.1.4修的时候失智了, 然后bug+=1

哈哈哈,可以可以,辛苦了