Skip to content

fix: substitute every ${VAR} reference when merging env files - #1829

Merged
Eduardo Villalpando Mello (edvilme) merged 1 commit into
microsoft:mainfrom
kwy404:fix/env-file-repeated-var-substitution
Oct 1, 2026
Merged

Eduardo Villalpando Mello (edvilme) merged 1 commit into
microsoft:mainfrom
kwy404:fix/env-file-repeated-var-substitution

Conversation

@kwy404

Copy link
Copy Markdown
Contributor

Problem

mergeEnvVariables expands ${VAR} references in env file values (the python.envFile file, the project .env and API overrides) with String.prototype.replace and a string pattern. That has two effects:

  • Only the first reference to a variable is replaced. With ROOT=/home/user in the base environment, PATHS=${ROOT}/a:${ROOT}/b becomes /home/user/a:${ROOT}/b.
  • $ sequences in the substituted value are read as replacement patterns. A base value of pa$$word comes out as pa$word.

Fix

Use split(token).join(value), which replaces every occurrence and inserts the value as is. (replaceAll is not available with the ES2020 lib target.)

Tests

Added src/test/features/execution/envVarUtils.unit.test.ts, which merges a value with a repeated ${ROOT} reference and a ${SECRET} whose base value contains $$. It fails before the fix (actual /home/user/a:${ROOT}/b) and passes after it.

  • npm run unittest (Windows, Node 24): 2430 passing, 4 pending.
  • eslint and prettier pass on the changed files.
@eleanorjboyd Eleanor Boyd (eleanorjboyd) added the bug Issue identified by VS Code Team member as probable bug label Sep 30, 2026
@rchiodo

Rich Chiodo (rchiodo) commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR.

@rchiodo

Copy link
Copy Markdown
Contributor

Result: 🔴 could-not-verify

Verification details

Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified.

Summary: [unavailable] Container verification could not start and local execution was not authorized for this PR HEAD: Podman machine 'pyrx-automation' is not running.

Test runs: none recorded.

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@rchiodo Rich Chiodo (rchiodo) added the review-auto:approved Automated review: no blocking findings (approval posted). label Oct 1, 2026
@edvilme

Copy link
Copy Markdown
Contributor

Hello Alexandre Kohler (@kwy404) thank you so much for working on this. Changes look good :)

@edvilme
Eduardo Villalpando Mello (edvilme) merged commit 4ab81cf into microsoft:main Oct 1, 2026
47 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug review-auto:approved Automated review: no blocking findings (approval posted).

4 participants