Skip to content

Commit 64f5132

Browse files
Ilanlidoclaude
andcommitted
CM-64462: fix plugin registry file-URI parsing on Windows
url2pathname handles drive-letter file URIs (file:///C:/...) that a bare urlparse().path mangles with a leading slash; also build the pluginLocations test fixture with json.dumps so Windows path separators are escaped. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent a33c2da commit 64f5132

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

cycode/cli/apps/ai_guardrails/ides/copilot.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from collections.abc import Iterable
2121
from pathlib import Path
2222
from typing import ClassVar, Optional, Union
23-
from urllib.parse import unquote, urlparse
23+
from urllib.parse import urlparse
24+
from urllib.request import url2pathname
2425

2526
from cycode.cli.apps.ai_guardrails.consts import CYCODE_SCAN_PROMPT_COMMAND, CYCODE_SESSION_START_COMMAND
2627
from cycode.cli.apps.ai_guardrails.ides._plugin_utils import (
@@ -212,7 +213,8 @@ def _vscode_registry_plugins() -> dict:
212213
entries[key] = plugin
213214
uri = plugin.get('pluginUri', '')
214215
if uri.startswith('file://'):
215-
dirs[key] = Path(unquote(urlparse(uri).path))
216+
# url2pathname unquotes and handles Windows drive-letter URIs (file:///C:/...).
217+
dirs[key] = Path(url2pathname(urlparse(uri).path))
216218
return _walk_registry_plugins(entries, dirs, is_enabled=False)
217219

218220

tests/cli/commands/ai_guardrails/ides/test_copilot.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,10 +380,11 @@ def test_local_dir_plugins_from_plugin_locations_setting(fs: FakeFilesystem) ->
380380
disabled_dir = Path('/plugins/disabled-plugin')
381381
_create_plugin_on_disk(fs, enabled_dir, manifest_location='plugin.json')
382382
_create_plugin_on_disk(fs, disabled_dir, manifest_location='plugin.json')
383-
locations = f'{{"{enabled_dir}": true, "{disabled_dir}": false}}'
383+
# json.dumps escapes Windows path separators; the comment line exercises JSONC handling.
384+
settings = json.dumps({'chat.pluginLocations': {str(enabled_dir): True, str(disabled_dir): False}})
384385
fs.create_file(
385386
_vscode_mcp_config_path().parent / 'settings.json',
386-
contents=f'{{\n// user settings\n"chat.pluginLocations": {locations}\n}}',
387+
contents=f'// user settings\n{settings}',
387388
)
388389

389390
_, plugins = Copilot().get_session_context()

0 commit comments

Comments
 (0)