fix(wechat): Windows 系统上 doctor 误判微信公众号渠道不可用#263
Open
Pgooone wants to merge 1 commit intoPanniantong:mainfrom
Open
fix(wechat): Windows 系统上 doctor 误判微信公众号渠道不可用#263Pgooone wants to merge 1 commit intoPanniantong:mainfrom
Pgooone wants to merge 1 commit intoPanniantong:mainfrom
Conversation
在 Windows 中文系统上,subprocess.run 使用 text=True 时默认以 gbk 编码读取 mcporter config list 的输出,当输出中包含特殊 字符(如 UTF-8 的 0x94)时会抛出 UnicodeDecodeError,导致 _exa_available() 返回 False,进而使 agent-reach doctor 误判 微信公众号文章渠道为 [X] 不可用。 本修复将 text=True 替换为 encoding="utf-8", errors="replace", 与 exa_search.py 中的做法保持一致。 Closes #ISSUE_ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
修复 Windows 中文系统上
agent-reach doctor因编码问题误判微信公众号文章渠道不可用的 bug。根因分析
agent_reach/channels/wechat.py中_exa_available()使用subprocess.run(..., text=True, ...),在未指定编码时,Windows 中文环境默认使用 gbk 解码mcporter config list的输出。当输出中包含 UTF-8 特殊字符(如0x94)时,抛出UnicodeDecodeError,异常被捕获后函数返回False,导致 doctor 显示[X]。但这是假阴性,mcporter + Exa 实际完全可用。改动内容
text=True改为encoding="utf-8", errors="replace"exa_search.py中的处理方式保持一致验证结果
修复前:
UnicodeDecodeError: 'gbk' codec can't decode byte 0x94[X]修复后:
exa.web_search_exa和exa.web_fetch_exa读取公众号文章功能正常Fixes #262