Skip to content

Commit e6c859d

Browse files
author
Kartik Raj
authored
Add more validation checks when accessing envs from cache (#22966)
Failing tests are not related to the PR, so this is ready for review. For #22877
1 parent fa75337 commit e6c859d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/client/pythonEnvironments/base/locators/composite/envsCollectionCache.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ export class PythonEnvInfoCache extends PythonEnvsWatcher<PythonEnvCollectionCha
245245
// Any environment with complete information is flushed, so this env does not contain complete info.
246246
return false;
247247
}
248+
if (env.version.micro === -1 || env.version.major === -1 || env.version.minor === -1) {
249+
// Env should not contain incomplete versions.
250+
return false;
251+
}
248252
const { ctime, mtime } = await getFileInfo(env.executable.filename);
249253
if (ctime !== -1 && mtime !== -1 && ctime === env.executable.ctime && mtime === env.executable.mtime) {
250254
return true;

src/test/pythonEnvironments/base/locators/composite/envsCollectionService.unit.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ suite('Python envs locator - Environments Collection', async () => {
7878
) {
7979
const env = buildEnvInfo({ executable, searchLocation, name, location, kind });
8080
env.id = id ?? env.id;
81+
env.version.major = 3;
82+
env.version.minor = 10;
83+
env.version.micro = 10;
8184
return env;
8285
}
8386

0 commit comments

Comments
 (0)