Skip to content

Filter invalid Windows env var names before passing to child_process#2634

Merged
nagilson merged 9 commits intomainfrom
copilot/fix-installer-invalid-env-var
Apr 10, 2026
Merged

Filter invalid Windows env var names before passing to child_process#2634
nagilson merged 9 commits intomainfrom
copilot/fix-installer-invalid-env-var

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Windows environment variables like CommonProgramFiles(x86) and ProgramFiles(x86) contain parentheses, which newer Node.js versions reject when passed via options.env to child_process.exec, causing SDK installs to fail with options.env has an invalid environment variable name: "CommonProgramFiles(x86)".

Changes

  • TypescriptUtilities.ts: Added isValidEnvironmentVariableName(name) and filterEnvVars(env) — filters out env vars whose names contain parentheses (the character class Node.js rejects in options.env)
  • CommandExecutor.ts: Apply filterEnvVars() in both code paths where process.env is spread into options.env
// Before
options.env ??= { ...process.env };

// After
options.env ??= filterEnvVars({ ...process.env });
  • TypescriptUtilities.test.ts: Unit tests covering both isValidEnvironmentVariableName and filterEnvVars for the parentheses case and standard valid names

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • microsoft.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/vscode-dotnet-runtime/vscode-dotnet-runtime/vscode-dotnet-runtime-library/node_modules/.bin/mocha -u tdd -- dist/test/unit/DebianDistroTests.test.js dist/test/unit/DotnetConditionValidator.test.js dist/test/unit/DotnetCoreAcquisitionWorker.test.js dist/test/unit/DotnetPathFinder.test.js dist/test/unit/DotnetResolver.test.js dist/test/unit/ErrorHandler.test.js dist/test/unit/ExecutableArchitectureDetector.test.js dist/test/unit/ExistingPathResolver.test.js dist/test/unit/FileUtilities.test.js dist/test/unit/GlobalInstallerResolver.test.js dist/test/unit/InstallScriptAcquisitionWorker.test.js dist/test/unit/InstallTracker.test.js dist/test/unit/InstallationValidator.test.js dist/test/unit/IssueReporter.test.js dist/test/unit/JsonInstaller.test.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI and others added 2 commits April 8, 2026 23:37
Copilot AI changed the title [WIP] Fix installer failure due to invalid environment variable Filter invalid Windows env var names before passing to child_process Apr 8, 2026
Copilot AI requested a review from nagilson April 8, 2026 23:48
nagilson and others added 2 commits April 9, 2026 10:29
- Use POSIX regex /^[a-zA-Z_][a-zA-Z0-9_]*$/ instead of only filtering ()
  to match what @vscode/sudo-prompt actually validates
- Fix comments: error comes from sudo-prompt, not Node.js child_process
- Add tests for hyphens, dots, spaces, digit-leading names, empty string
- Revert yarn.lock platform artifact (linux-x64 back to win32-x64)
- Add trailing newline to TypescriptUtilities.ts

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nagilson nagilson force-pushed the copilot/fix-installer-invalid-env-var branch from 409b8d6 to 0e21ea4 Compare April 9, 2026 22:26
nagilson and others added 3 commits April 9, 2026 15:29
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nagilson nagilson marked this pull request as ready for review April 9, 2026 22:32
@nagilson nagilson requested a review from a team April 9, 2026 22:32
@nagilson nagilson enabled auto-merge April 9, 2026 23:11
@nagilson nagilson merged commit 7f5a994 into main Apr 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installer Failed with options.env has an invalid environment variable name: "CommonProgramFiles(x86)

3 participants