🐛 fix(mcp): 统一元数据响应 JSON 序列化 - #158
Merged
Merged
Conversation
Owner
Author
阶段回帖 1/2:实现完成来源与问题复现
实现证据
兼容性边界本 PR 只改变序列化入口,不改变 SQL、分页、安全规则、事务、权限、metadata 字段语义、同步 API 或 Raw Response 顶层字段。合法 JSON 基本类型的输出保持一致;没有真实 MySQL/PostgreSQL 吞吐或生产值类型的未经证实声明。 |
Owner
Author
阶段回帖 2/2:验证完成环境与固定输入
命令与原始结果验收结果
未执行与风险
|
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
Closes #157
本 PR 统一元数据和代码生成成功响应的 JSON 序列化,避免驱动值导致 MCP 返回 generic error。
背景(Situation)
元数据 handler 仍有多条裸 json.dumps 路径。MySQL/PostgreSQL 驱动可能返回 Decimal、date/datetime、UUID、bytes 或 memoryview,使 describe、columns、primary keys、foreign keys、indexes 和 codegen analyze 的 Raw Response 序列化失败。
任务(Task)
复用查询工具已有的值编码合同,在不改变 SQL、元数据字段、文本摘要、错误类型或同步 API 的前提下,保留 Decimal 精度与二进制身份,并补齐可复现回归测试。
行动(Action)
验证(Verification)
环境:Windows;Python 3.10.1;pytest 9.0.3;pytest-asyncio 1.3.0。
实验与证据(Evidence)
固定 PostgreSQL mock 元数据注入 Decimal 12.30、UTC datetime、UUID 和 memoryview。五类 metadata handler 的 Raw Response 均可 json.loads;memoryview 编码为 encoding=base64 对象;codegen analyze 的嵌套 Decimal 也可编码。未知对象继续进入显式 TypeError。无真实 MySQL/PostgreSQL 驱动值结论。
兼容性、风险与回滚
公共工具名、输入 schema、响应字段和人类可读文本保持不变;合法 JSON 基本类型输出不变。依赖旧序列化失败字符串的客户端会收到可解析成功 payload,这是预期修复;未知对象仍失败。恢复提交 52a1eca 可回滚,不涉及数据迁移;后续在容器中补充 MySQL/PostgreSQL 驱动值类型证据。