🧪 test(mcp): 补充成功响应 JSON 回归 - #112
Merged
Merged
Conversation
Owner
Author
|
问题复现:成功响应的 Raw Response 在多个工具中使用 Python repr,布尔值、空值和字符串格式不符合 JSON;失败响应却使用 json.dumps,造成同一 MCP 边界两套协议。 |
Owner
Author
|
实现记录:统一连接、表存在性、查询、表描述、列、主键、外键和索引成功路径的 JSON 序列化,保留用户可读摘要和既有字段名。 |
Owner
Author
|
实验结果:对 Raw Response 片段执行 json.loads,查询和表存在性路径由失败变为成功,True/None/list 等值保持 JSON 语义。 |
Owner
Author
|
测试记录:定向 MCP 回归 30 项通过,完整单元测试 651 项通过,Ruff 检查与 diff 检查通过。 |
Owner
Author
|
兼容性边界:客户端应按 JSON 解析,不再依赖 Python repr;本次未建立可比性能基准,性能数据未测量。 |
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.
关联 Issue
Refs #107
背景(Situation)
该历史 PR 与 #110 共享同一实现提交
fc01c97,展示层此前重复使用:bug: fix(mcp): 统一成功响应 JSON 序列化标题和同一段简短正文,无法区分实现记录与回归记录,也使 Issue/PR 关系不清晰。任务(Task)
将本条历史记录明确标识为成功响应 JSON 回归覆盖,保留可追溯的输入、结果和边界;不伪造第二份实现或新的运行时行为。
行动(Action)
:test_tube: test(mcp): 补充成功响应 JSON 回归,与记录职责一致。json.loads断言、成功/失败 envelope 和未测边界。mcp_tools.py,不改变公共 payload,不重写合并提交历史。验证(Verification)
环境:Windows 11,Python 3.12.12。
PYTHONPATH=src python -m pytest tests/unit/ -q:651 passed。ruff check src tests scripts、格式检查和git diff --check:通过。实验与证据(Evidence)
受控成功查询和表存在性响应经
json.loads均可解析;success=false错误 envelope 仍保持 JSON。该 PR 不声称新增代码,只把重复历史记录、验证结果和边界补充清楚。兼容性、风险与回滚
fc01c97提交标题仍不可变;PR 标题用于浏览,不能替代 commit object。