-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
When Copilot Chat asks the host to run a command, the extension sometimes forwards file:// URIs (e.g. file:///tmp/foo) directly to Node's child_process APIs. On Linux this can cause ENOPRO errors because spawn/execFile expect filesystem paths, not file:// URIs.
Steps to reproduce
- VS Code + Copilot Chat extension v0.40.1 on Debian GNU/Linux 13 (Code 1.112.0).
- Ask Copilot Chat to run a terminal command that includes a local path (observed when paths are forwarded as
file://…). - Observe the command fails and extension logs show the
child_processerror andspawnargscontainingfile://-prefixed arguments.
Attach when filing
- Full
child_processerror object (errno,code,syscall,path,spawnargs). - Extension debug log around the spawn/exec call showing exact command and args.
- Minimal Copilot Chat prompt that produced the command.
Related discussion
https://github.com/orgs/community/discussions/179557
Root cause (diagnosis)
Arguments are not normalized before passing into child_process. file: URLs must be converted to filesystem paths before being passed to spawn/execFile.
Proposed fix
Sanitize arguments at the command-runner boundary: convert file: URLs to filesystem paths using Node's fileURLToPath (from the url module) prior to calling spawn/execFile. Leave non-file schemes unchanged or validate them explicitly.
Implementation sketch
- Add
sanitizeArg(arg)/sanitizeArgs(args)utility that:- returns
fileURLToPath(new URL(arg))forfile:URLs, - returns plain paths unchanged,
- leaves or validates other schemes.
- returns
- Call
sanitizeArgs()immediately before anyspawn/execFile/execinvocation.
Tests to add
- Unit:
file:///tmp/example->/tmp/example;file:///C:/Windows-> containsC:;/usr/bin-> unchanged;vscode-remote://...-> unchanged or flagged. - Integration: spawn a helper script with
['file:///tmp/testfile']and assert spawned argv is/tmp/testfileand no ENOPRO occurs.
Call to action
Please triage; I can prepare a PR with the sanitizer and tests — attach the child_process error object and the pre-spawn argument list to help triage.