Skip to content

Add more validation checks when accessing envs from cache #22966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ export class PythonEnvInfoCache extends PythonEnvsWatcher<PythonEnvCollectionCha
// Any environment with complete information is flushed, so this env does not contain complete info.
return false;
}
if (env.version.micro === -1 || env.version.major === -1 || env.version.minor === -1) {
// Env should not contain incomplete versions.
return false;
}
const { ctime, mtime } = await getFileInfo(env.executable.filename);
if (ctime !== -1 && mtime !== -1 && ctime === env.executable.ctime && mtime === env.executable.mtime) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ suite('Python envs locator - Environments Collection', async () => {
) {
const env = buildEnvInfo({ executable, searchLocation, name, location, kind });
env.id = id ?? env.id;
env.version.major = 3;
env.version.minor = 10;
env.version.micro = 10;
return env;
}

Expand Down