Skip to content

Copilot Chat: child_process ENOPRO when file:// URIs are passed to commands #304555

@darrenoh

Description

@darrenoh

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

  1. VS Code + Copilot Chat extension v0.40.1 on Debian GNU/Linux 13 (Code 1.112.0).
  2. Ask Copilot Chat to run a terminal command that includes a local path (observed when paths are forwarded as file://…).
  3. Observe the command fails and extension logs show the child_process error and spawnargs containing file://-prefixed arguments.

Attach when filing

  • Full child_process error 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)) for file: URLs,
    • returns plain paths unchanged,
    • leaves or validates other schemes.
  • Call sanitizeArgs() immediately before any spawn/execFile/exec invocation.

Tests to add

  • Unit: file:///tmp/example -> /tmp/example; file:///C:/Windows -> contains C:; /usr/bin -> unchanged; vscode-remote://... -> unchanged or flagged.
  • Integration: spawn a helper script with ['file:///tmp/testfile'] and assert spawned argv is /tmp/testfile and 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions