Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 使用HttpServerConfig配置时,传入的qq头有误会导致服务端返回500错误 #230

Closed
EZForever opened this issue May 1, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@EZForever
Copy link

EZForever commented May 1, 2023

问题

使用HttpServerConfig(即Webhook)配置时,若MAH传入的请求来自未在Ariadne中配置的QQ号,下列代码会触发:

if req.headers.get("qq") != str(self.info.account):
return

这将向其调用者返回None。而其调用者显然是不支持None的,抛出TypeError异常,进而导致返回500:

https://github.com/GraiaProject/Amnesia/blob/v0.7.1/src/graia/amnesia/builtins/aiohttp.py#L439-L448

如何复现

使用HttpServerConfig配置启动Ariadne,向其监听的端口发送任意请求。当请求头qq与Ariadne配置不同时,可以注意到返回500错误,且控制台提示异常ValueError: unsupported response type <class 'NoneType'>

预期行为

指定在此情况下的错误码。鉴于MAH Webhook Adapter文档并未指定在此种情况下应当返回的错误码,建议使用MAH API文档中提及的400错误,即替换returnreturn "Bad Request", {"status": 400}

使用环境:

#229

日志/截图

@EZForever EZForever added bug Something isn't working triage Further information is requested labels May 1, 2023
@BlueGlassBlock BlueGlassBlock removed the triage Further information is requested label May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants