From 81fa17c15ab2b1a4a610363be74003efb21a1cb1 Mon Sep 17 00:00:00 2001 From: xiaodu55 <1704788159@qq.com> Date: Wed, 30 Sep 2026 09:19:39 +0800 Subject: [PATCH] fix(gateway): render the bundled interpreter repair path without backslash escapes (#6040) * fix(gateway): render the bundled interpreter repair path without backslash escapes The repair hint used {sys.executable!r}, whose repr() escapes Windows backslashes - users saw 'D:\college\...\python.exe' in the copy-paste guidance, and test_stale_bundled_interpreter_can_be_repaired_without_reinstall fails 3/3 on Windows because the raw path never appears in the detail. The !r was written for the surrounding quotes; on POSIX paths that is its only effect, which is why CI never saw it. Quote the raw path explicitly instead. On Windows the three test params now pass (22/22 in the file); POSIX output is unchanged apart from the quoting coming from the literal instead of repr(). * fix(gateway): json-escape the interpreter command in the repair hint Review follow-up (P2): the raw Windows path in the hint cannot be pasted into the server's JSON ('\U' is not a JSON escape), so the prescribed repair could not be saved. Show the command value via json.dumps(sys.executable) - pasteable JSON on every platform - and keep the raw path in a parenthetical for terminal use, per review. --- backend/app/gateway/routers/mcp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/app/gateway/routers/mcp.py b/backend/app/gateway/routers/mcp.py index 3e6e9f9588..7c54daba0d 100644 --- a/backend/app/gateway/routers/mcp.py +++ b/backend/app/gateway/routers/mcp.py @@ -1,4 +1,5 @@ import asyncio +import json import logging import os import re @@ -793,7 +794,8 @@ def _validate_mcp_update_request( status_code=status.HTTP_400_BAD_REQUEST, detail=( f"Bundled MCP server '{name}' uses a different Python interpreter. " - f"Edit this server's JSON and set 'command' to {sys.executable!r}. " + f"Edit this server's JSON and set 'command' to {json.dumps(sys.executable)} " + f"(raw path for terminal use: {sys.executable}). " "Keep its capability metadata and credentials unchanged to preserve Agent selections; do not delete and reinstall it." ), )