From bdbfca77e578468a756d68e3dbe44a5a587cd5d0 Mon Sep 17 00:00:00 2001 From: Wolfvin Date: Mon, 13 Jul 2026 19:38:54 +0700 Subject: [PATCH] fix: repair sarif f-string SyntaxError + _auto_setup gate regression --- scripts/codelens.py | 15 ++++++++------- scripts/formatters/sarif.py | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/codelens.py b/scripts/codelens.py index d79b1ae5..8c0577f5 100755 --- a/scripts/codelens.py +++ b/scripts/codelens.py @@ -1445,15 +1445,16 @@ def main(): ) # ─── Auto-setup: if command needs registry and none exists, bootstrap it ──── - # Commands that need a registry to work meaningfully - _REGISTRY_COMMANDS = { - "search", "context", "deps", "audit", "security", - "summary", "impact", "api-map", "doctor", "history", - "graph", - } + # `scan` BUILDS the registry; `plugin`/`lsp` don't read it. Every other + # command — visible umbrella OR hidden leaf (list, query, ...) — consumes the + # registry and benefits from auto-setup when it's absent. Deriving the gate + # from this small exclusion set (rather than a hand-maintained allowlist) + # avoids the stale-list bug that let audit/security/deps/doctor and the hidden + # leaf commands slip through the gate (issue #244). + _NON_REGISTRY_COMMANDS = {"scan", "plugin", "lsp"} auto_setup_info = None - if args.command in _REGISTRY_COMMANDS and not _registry_exists(workspace): + if args.command not in _NON_REGISTRY_COMMANDS and not _registry_exists(workspace): auto_setup_result = _auto_setup(workspace) if auto_setup_result.get("auto_setup") == "ok": auto_setup_info = { diff --git a/scripts/formatters/sarif.py b/scripts/formatters/sarif.py index 1843757d..60363ccc 100644 --- a/scripts/formatters/sarif.py +++ b/scripts/formatters/sarif.py @@ -462,9 +462,12 @@ def to_sarif(data: Dict, command: str = "", workspace: str = "", # Add workspace info if workspace: + # Note: the .replace() is kept out of the f-string expression — a + # backslash inside an f-string `{...}` is a SyntaxError on Python < 3.12. + workspace_uri = workspace.replace('\\', '/') run["originalUriBaseIds"] = { "%SRCROOT%": { - "uri": f"file://{workspace.replace('\\', '/')}/", + "uri": f"file://{workspace_uri}/", } }