8cde2273cb5de213acdc6ba91a8e5620b63fa2ac486fe2c78504eeccd99adfe5da8b7ed0ba5aa045本次提交为极小型变更,仅 1 个文件、1 行代码:
| 文件 | 变更类型 | 说明 |
|---|---|---|
backend/src/tools/graph_query_tool.py | 修改(1 行) | _run_async 中 action 受限时的错误返回补充 ensure_ascii=False |
变更内容:
@@ -116,7 +116,7 @@ class GraphQueryTool(BaseTool):
) -> str:
if self.restrict_actions and action not in self.restrict_actions:
- return json.dumps({"error": f"action '{action}' is restricted on this tool instance. Allowed: {self.restrict_actions}"})
+ return json.dumps({"error": f"action '{action}' is restricted on this tool instance. Allowed: {self.restrict_actions}"}, ensure_ascii=False)
基于 codescan_issues_diff 对 base..head 的真实比对结果:
两版本质检问题集合完全一致,本次变更未修复任何已登记问题,也未引入任何新登记问题。
backend/src/tools/graph_query_tool.py变更性质:编码一致性修复(编码/正确性无关的功能对齐),非逻辑变更。
上下文:
_run_async 是 GraphQueryTool 的异步执行入口(_arun 经 GLOBAL_TOOL_SEMAPHORE 调用)。restrict_actions 且请求的 action 不在白名单内时,函数直接返回一条 JSON 错误串。restrict_actions 中的中文动作名/提示文本,或调用方传入的 action 值)。影响评估:
ensure_ascii=True,中文等字符会被转义为 \uXXXX 形式,与工具内其他 JSON 输出(如同文件的 result_str = json.dumps(result, ensure_ascii=False, default=str) 及末尾业务错误返回 json.dumps({...}, ensure_ascii=False))不一致,LLM 侧可读性差。ensure_ascii=False,与文件内既有约定对齐,输出更可读,行为语义无风险(仅影响序列化转义,不改变 JSON 结构或字段)。结论:属于合理、低风险的一致性修正,方向正确。
backend/src/tools/graph_query_tool.py 在 head 版本存在 9 条存量质检问题(base 版本同样存在,非本次引入):
| 严重度 | 类型 | 位置 | 说明 |
|---|---|---|---|
| Low | Maintainability | L35 | 行超过 120 字符 |
| Low | Complexity | L102 | _run_async 参数过多(13 个) |
| Low | Maintainability | L103 | 重复代码块(4 行 ×3 处) |
| Medium | Complexity | L172 | _execute_action 圈复杂度高(13) |
| Medium | Complexity | L172 | _execute_action 函数过长(88 行) |
| Low | Complexity | L172 | _execute_action 参数过多(13 个) |
| Medium | Complexity | L261 | 圈复杂度高(13) |
说明:以上问题与本次变更无关,本次未触及对应代码区域。
json.dumps 调用换行,或抽取"受限动作错误"为私有方法,顺带缓解同文件 _execute_action / _execute_action_async 之间的重复代码块(L103)与参数过多(13 个)问题。json.dumps 的 ensure_ascii 使用一致性巡检,避免同类"漏加 ensure_ascii=False"的零散不一致再次出现。本次提交为单行编码一致性修复,使受限 action 的错误输出与文件中其他 JSON 输出保持一致,未修复、也未引入任何登记质检问题,风险极低,可正常合入。存量复杂度/重复代码问题与本次变更无关,不计入本次增量结论。
_execute_action_async| Medium | Complexity | L261 | _execute_action_async 函数过长(90 行) |
| Low | Complexity | L261 | _execute_action_async 参数过多(13 个) |