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.
This commit is contained in:
xiaodu55 2026-09-30 09:19:39 +08:00 committed by GitHub
parent fbf34e9cfc
commit 81fa17c15a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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."
),
)