Skip to content

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
mainfrom
dependabot/npm_and_yarn/examples/sample1/js-yaml-4.2.0
Open

fix: use deterministic environment ID to resolve "File in project uses project environment" integration test failure#1589
dependabot[bot] wants to merge 2 commits into
mainfrom
dependabot/npm_and_yarn/examples/sample1/js-yaml-4.2.0

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

createPythonEnvironmentItem used Math.random() to generate an ID suffix, so resolving the same Python executable twice produced objects with different IDs. The failure sequence:

  1. setEnvironment(projectUri, env) persists the selection to python-envs.pythonProjects in settings.json.
  2. registerInterpreterSettingsChangeListener fires applyInitialEnvironmentSelection in response to the settings change.
  3. applyInitialEnvironmentSelection re-resolves the same interpreter path, calling createPythonEnvironmentItem again — producing a new object with a different random ID — and overwrites the in-memory state.
  4. The subsequent getEnvironment(fileUri) call returns the overwritten env with the wrong ID, causing the assertion to fail.

Changes Made

  • src/features/pythonApi.ts: Replaced Math.random().toString(36).substring(2) in createPythonEnvironmentItem with a deterministic djb2-style hash of the normalized environmentPath.fsPath. The path is normalized via normalizePath() 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

  • ✅ Lint passes
  • ✅ TypeScript compilation passes
  • ✅ 1192 unit tests pass
  • ✅ CodeQL security scan: no alerts

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>
@dependabot dependabot Bot added dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code labels Jun 16, 2026
dmitrivMS
dmitrivMS previously approved these changes Jun 16, 2026
rzhao271
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 dismissed stale reviews from rzhao271 and dmitrivMS via a2c697f June 17, 2026 00:11
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
Copilot AI requested a review from rzhao271 June 17, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file javascript Pull requests that update javascript code no-changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants