Fix wecom adapter returning json instead of plain text#9107
Fix wecom adapter returning json instead of plain text#9107Makarov3821 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="astrbot/core/platform/sources/wecom/wecom_adapter.py" line_range="120" />
<code_context>
async def handle_verify(self, request) -> str:
</code_context>
<issue_to_address>
**issue:** Return type annotation no longer matches the actual Response return value.
This function is annotated to return `str` but now returns a `FastAPIResponse`, creating a contract mismatch for callers and type checkers. Please update the return annotation (and any related interfaces) to use the appropriate `Response` type so the signature reflects the actual behavior.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Code Review
This pull request modifies the WeCom adapter to return a FastAPIResponse instead of a plain string during verification, and updates the dashboard API runner to handle Response objects directly. The review feedback correctly suggests updating the return type annotation of handle_verify to FastAPIResponse to ensure type safety and prevent static analysis errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| ) | ||
| logger.info("验证请求有效性成功。") | ||
| return echo_str | ||
| return FastAPIResponse(content=echo_str, media_type="text/plain") |
对#9077 的修复,对于企业微信客服的验证返回纯文本而不是json,以避免回调验证失败
Modifications / 改动点
修改了astrbot/core/platform/sources/wecom/wecom_adapter.py和astrbot/dashboard/api/platform.py两处五行,在reponse输出前进行重整。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Ensure WeCom platform verification callbacks return the expected plain-text HTTP response instead of JSON-wrapped data.
Bug Fixes:
Enhancements: