fix: use deterministic environment ID to resolve "File in project uses project environment" integration test failure#1589
Open
dependabot[bot] wants to merge 2 commits into
Conversation
Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 4.1.1 to 4.2.0. - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodeca/js-yaml/commits) --- updated-dependencies: - dependency-name: js-yaml dependency-version: 4.2.0 dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com>
dmitrivMS
previously approved these changes
Jun 16, 2026
rzhao271
previously approved these changes
Jun 16, 2026
…thonEnvironmentItem The integration test "File in project uses project environment" was failing because createPythonEnvironmentItem used Math.random() for the ID suffix. When setEnvironment() persists to python-envs.pythonProjects settings, registerInterpreterSettingsChangeListener re-triggers applyInitialEnvironmentSelection which re-resolves the same interpreter path — but creates a new object with a different random ID — and overwrites the in-memory state. The subsequent getEnvironment(fileUri) call then returns the wrong ID. Fix: replace Math.random() with a deterministic djb2-style hash of the normalized executable path so the same interpreter always maps to the same ID regardless of how many times it is resolved.
Copilot
AI
changed the title
chore(deps-dev): bump js-yaml from 4.1.1 to 4.2.0 in /examples/sample1
fix: use deterministic environment ID to resolve "File in project uses project environment" integration test failure
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the failing CI job "Integration Tests (ubuntu-latest, 3.14)" — specifically the test "Integration: Python Projects > File in project uses project environment".
Root Cause
createPythonEnvironmentItemusedMath.random()to generate an ID suffix, so resolving the same Python executable twice produced objects with different IDs. The failure sequence:setEnvironment(projectUri, env)persists the selection topython-envs.pythonProjectsinsettings.json.registerInterpreterSettingsChangeListenerfiresapplyInitialEnvironmentSelectionin response to the settings change.applyInitialEnvironmentSelectionre-resolves the same interpreter path, callingcreatePythonEnvironmentItemagain — producing a new object with a different random ID — and overwrites the in-memory state.getEnvironment(fileUri)call returns the overwritten env with the wrong ID, causing the assertion to fail.Changes Made
src/features/pythonApi.ts: ReplacedMath.random().toString(36).substring(2)increatePythonEnvironmentItemwith a deterministic djb2-style hash of the normalizedenvironmentPath.fsPath. The path is normalized vianormalizePath()to handle case-insensitive file systems (e.g. Windows). This guarantees that resolving the same interpreter path always produces the same environment ID, regardless of how many times it is resolved.Testing