Fix flaky Python project environment identity assertions - #1725
Merged
Stella Huang (StellaHuang95) merged 1 commit intoAug 18, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3cb82ae9-7424-40a4-9156-8c54ac6e0895
Contributor
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
Comment on lines
+29
to
+35
| function getEnvironmentIdentity(environment: PythonEnvironment) { | ||
| return { | ||
| managerId: environment.envId.managerId, | ||
| path: normalizePath(environment.environmentPath.fsPath), | ||
| version: environment.version, | ||
| }; | ||
| } |
Contributor
There was a problem hiding this comment.
Could/should we somehow hash them so we only have to compare the hashes?
Eduardo Villalpando Mello (edvilme)
approved these changes
Aug 18, 2026
Rich Chiodo (rchiodo)
approved these changes
Aug 18, 2026
Rich Chiodo (rchiodo)
left a comment
Contributor
There was a problem hiding this comment.
Approved via Review Center.
Stella Huang (StellaHuang95)
merged commit Aug 18, 2026
6104bbb
into
microsoft:main
85 of 88 checks passed
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.
Context
The macOS 3.12 integration job in recent prs failed in
Integration: Python Projects > File in project uses project environmentThe assertion showed the same Python version with two different generated suffixes:
Root cause
PythonEnvironmentApiImpl.createPythonEnvironmentItem()appendsMath.random()when creatingenvId.id. A manager may rematerialize the same logical interpreter from its persisted path duringgetEnvironment(), producing a fresh object and random ID.The Python Projects integration suite compared
envId.idto verify:Those checks can fail even when the manager, executable path, and Python version are all correct.
Fix
Use one logical-environment identity throughout this suite:
The shared helper now drives candidate selection, event filtering, and all project/file readback assertions. The event helper still subscribes before
setEnvironment(), so this does not reintroduce the settings-persistence race that the event-driven test was designed to avoid.The event-specific test also reuses the URI-and-environment-filtered helper instead of accepting any later event with a non-empty
newvalue.Why this is test-only
This suite verifies project association and inheritance, not the long-term stability contract of
envId.id. Changing production ID generation here would be a broad public-API and cache-semantics change: environment IDs key package caches, watchers, terminals, tree items, and active-selection equality. Managers also do not consistently representenvironmentPathas the same kind of path.Production
envIdstability is worth evaluating separately. This focused fix keeps the integration assertion strict while avoiding an unrelated cross-cutting behavior change.Validation
npm run compile-testsIntegration: Python Projectssuite: 8 passingA full local integration run reached and passed the changed Python Projects suite, then failed later in unrelated environment-creation tests. The separate Ubuntu package-network failure from the same CI run is not addressed by this PR.