Path-only pythonProjects entries crash manager initialization
@eleanorjboyd ci sta già lavorando.
Dal 5/8/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Environment data
- Python Environments extension version: 1.36.0 (latest Marketplace stable); also reproduced from
mainatf61acdf535b9c8e8983e6b600048f3f4de1425e1(package version 1.37.0) - Python extension (
ms-python.python) version: 2026.4.0 - VS Code version (Help → About): 1.130.0 (
1b6a188127eeaf9194f945eb6eb89a657e93c54c) - OS and version: macOS 15.3.2 arm64
- Python version: 3.9.6
- Environment manager in use:
venv - Shell: zsh
- Remote / container scenario: none
- Workspace type: single-folder mono-repo
- Is this a regression? Unknown
Repro Steps
-
Start VS Code with empty
--user-data-dirand--extensions-dirdirectories. -
Install only
ms-python.pythonandms-python.vscode-pylance; this installsms-python.vscode-python-envsas a dependency. -
Open a fresh folder containing
backend/main.pyandbackend/.venv. -
Add the following workspace settings:
{ "python.useEnvironmentsExtension": true, "python.analysis.usePerProjectEnvironments": true, "python-envs.pythonProjects": [ { "path": "backend" } ] } -
Reload the window and open
backend/main.py.
Expected behavior
The path-only project entry is accepted. Because envManager and packageManager are optional in the contributed setting schema, the extension uses python-envs.defaultEnvManager and python-envs.defaultPackageManager.
Actual behavior
Environment-manager initialization repeatedly throws TypeError: Cannot read properties of undefined (reading 'length'). Post-initialization telemetry and subsequent environment lookups fail, preventing reliable project environment resolution.
getDefaultEnvManagerSetting() and getDefaultPkgManagerSetting() dereference optional object properties without checking whether they exist:
if (settings && settings.envManager.length > 0) {
// ...
if (settings && settings.packageManager.length > 0) {
Explicitly adding both manager properties avoids the exception, but duplicates defaults that the setting schema already defines and should not be required.
Logs
Python-envs extension version: 1.36.0
Post-initialization tasks failed: TypeError: Cannot read properties of undefined (reading 'length')
at getDefaultEnvManagerSetting (.../ms-python.vscode-python-envs-1.36.0-darwin-arm64/dist/extension.js:2:389988)
at sendManagerSelectionTelemetry (.../dist/extension.js:2:286259)
TypeError: Cannot read properties of undefined (reading 'length')
at getDefaultEnvManagerSetting (.../ms-python.vscode-python-envs-1.36.0-darwin-arm64/dist/extension.js:2:389988)
at waitForEnvManager (.../dist/extension.js:2:313554)
at async getEnvironment (.../dist/extension.js:2:384509)
Additional context
The reproduction used a genuinely empty VS Code profile with no third-party extensions or pre-existing user settings.
A local fix that treats omitted manager properties as fallback-to-default values removes the runtime errors in a second fresh profile. It also passes the complete unit-test suite (1,429 passing) and lint.
AI disclosure: Prepared with assistance from OpenAI Codex.
- Lingua principale
- TypeScript
- Stelle
- 140
- Fork
- 63
- Merge medio
- 1g 4h
- PR unite (30g)
- 35
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/vscode-python-environments
-
microsoft/vscode-python-environments#1799 · 1 assegnatario ·
-
microsoft/vscode-python-environments#1796 · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
-
triage-needed
microsoft/vscode-python-environments#1791 · 1 reazione · 2 assegnatari ·
-
triage-needed
Difficoltà 4/5 3-5 giorni Idoneità per principianti 74/100
microsoft/vscode-python-environments#1779 · 1 commento · 1 reazione ·
Tutte le issue di microsoft/vscode-python-environments
Issue simili
-
Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
OpenNSW/nsw-srilanka#497 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
0xMiden/bridge-portal#132 ·
-
react-doctor severity:warning tech-debt
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
digidem/comapeo-cloud-app#403 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100