-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
perf: handle unsupported message types with logging in OneBot adapter #4164
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
Conversation
解决else 分支中对未知消息类型毫无防御,直接索引ComponentTypes[t],导致新类型markdown类信息报错并炸掉事件管道,且对应群聊单群永久不响应插件;尝试支持markdown类型进行支持但未经过测试
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - 我给出了一些总体反馈:
- 在新的
elif t == "markdown"分支中,m在当前作用域中被引用但没有定义(不同于遍历for m in m_group的at分支),所以这里同样很可能需要对m_group进行循环,以避免出现NameError,并正确处理多个 markdown 片段。 for m in m_group循环内部的if t not in ComponentTypes检查会对每个片段重复执行;可以考虑把这个保护性检查移到循环外部,这样每个分组只检查一次类型,如果不支持就尽早返回。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- In the new `elif t == "markdown"` branch, `m` is referenced without being defined in that scope (unlike the `at` branch which iterates `for m in m_group`), so you likely need a loop over `m_group` there as well to avoid a `NameError` and to handle multiple markdown segments correctly.
- The `if t not in ComponentTypes` check inside the `for m in m_group` loop runs redundantly for every segment; consider moving this guard outside the loop so you only check the type once per group and return early if unsupported.帮我变得更有用!请在每条评论上点一下 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've left some high level feedback:
- In the new
elif t == "markdown"branch,mis referenced without being defined in that scope (unlike theatbranch which iteratesfor m in m_group), so you likely need a loop overm_groupthere as well to avoid aNameErrorand to handle multiple markdown segments correctly. - The
if t not in ComponentTypescheck inside thefor m in m_grouploop runs redundantly for every segment; consider moving this guard outside the loop so you only check the type once per group and return early if unsupported.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the new `elif t == "markdown"` branch, `m` is referenced without being defined in that scope (unlike the `at` branch which iterates `for m in m_group`), so you likely need a loop over `m_group` there as well to avoid a `NameError` and to handle multiple markdown segments correctly.
- The `if t not in ComponentTypes` check inside the `for m in m_group` loop runs redundantly for every segment; consider moving this guard outside the loop so you only check the type once per group and return early if unsupported.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
bug产生的报错信息如下: |
解决else 分支中对未知消息类型毫无防御,直接索引ComponentTypes[t],导致新类型markdown类信息报错并炸掉事件管道,且对应群聊单群永久不响应全部插件(除非重启);尝试支持markdown类型进行支持但未经过测试。
Modifications / 改动点
对astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py中的函数_convert_handle_message_event做了健壮修改和对新类型markdown支持的尝试。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
以更稳健的方式处理不受支持的 aiocqhttp 消息段类型,避免破坏消息管道,并增加对 Markdown 消息段的初步支持。
Bug Fixes:
Enhancements:
Original summary in English
Summary by Sourcery
Handle unsupported aiocqhttp message segment types more defensively to avoid breaking the message pipeline and add initial support for markdown segments.
Bug Fixes:
Enhancements: