Repository navigation
Skip directory .env / python.envFile paths when resolving environment variables - #1865
Conversation
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
.env / python.envFile paths when resolving environment variables
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation correctly addresses directory paths while preserving existing precedence and error behavior.
0 open findings
What changed in this PR
Prevents environment-variable loading from attempting to parse directories as .env files.
Changes:
- Validates configured and project env paths as regular files.
- Preserves symlink handling and propagates unexpected filesystem errors.
- Adds coverage for directories, symlinks, precedence, and error cases.
| File | Description |
|---|---|
src/features/execution/envVariableManager.ts |
Adds regular-file validation before parsing env files. |
src/test/features/execution/envVariableManager.unit.test.ts |
Tests file types, symlinks, precedence, and filesystem errors. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
|
🔒 Automated review in progress — Heejae Chang (@heejaechang) is auto-reviewing this PR. |
|
Result: 🔴 Verification detailsVerification: 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: Could not prepare offline npm dependencies: Could not download semver@7.8.4 from the Microsoft package feed (ReadTimeout). Test runs: none recorded. |
Heejae Chang (heejaechang)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
Bill Schnurr (bschnurr)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
9f1e63d
into
main
If
<project>/.envwas a directory, for example a virtual environment named.env,getEnvironmentVariables()tried to read it as a file and threwEntryIsADirectory. That broke terminal env injection and Pylance. The same happened whenpython.envFilepointed at a directory. The cause was thefs-extrapathExistscheck, which also returns true for directories.Changes
envVariableManager.ts: bothpathExistschecks are replaced with a privateisEnvFilehelper, which accepts only regular files:stat, notlstat, so symlinks to regular files still load. Symlinks to directories are skipped.ENOENT/ENOTDIR(for example,EACCES) are still raised, not hidden.parseEnvFileis never called on a skipped path.envVariableManager.unit.test.ts): these callgetEnvironmentVariablesdirectly and cover:ENOTDIRbeing skipped, andEACCESbeing raisedNot changed
docs/README.mdstays the same: base →python.envFile→ project.env→ overrides. This PR does not implement the issue's separate request to havepython.envFilesuppress project.envdiscovery.statand the read can still fail.