-
Notifications
You must be signed in to change notification settings - Fork 38
Add error handling for broken Python environments #1189
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -128,6 +128,31 @@ function getName(binPath: string): string { | |||||
| } | ||||||
|
|
||||||
| async function getPythonInfo(env: NativeEnvInfo): Promise<PythonEnvironmentInfo> { | ||||||
| // Handle broken environments that have an error field | ||||||
| if (env.error) { | ||||||
| const venvName = env.name ?? (env.prefix ? path.basename(env.prefix) : 'Unknown'); | ||||||
| const name = `${venvName} (broken)`; | ||||||
|
||||||
|
|
||||||
| return { | ||||||
| name: name, | ||||||
| displayName: name, | ||||||
| shortDisplayName: `(${venvName})`, | ||||||
| displayPath: env.prefix ?? env.executable ?? 'Unknown path', | ||||||
| version: env.version ?? 'Unknown', | ||||||
| description: env.error, | ||||||
| tooltip: env.error, | ||||||
| environmentPath: Uri.file(env.prefix ?? env.executable ?? ''), | ||||||
|
||||||
| iconPath: new ThemeIcon('warning'), | ||||||
| sysPrefix: env.prefix ?? '', | ||||||
|
||||||
| sysPrefix: env.prefix ?? '', | |
| sysPrefix: env.prefix ?? (env.executable ? path.dirname(env.executable) : ''), |
Copilot
AI
Feb 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new error handling logic for broken environments in getPythonInfo() and findVirtualEnvironments() lacks test coverage. The codebase has comprehensive test coverage for other parts of venvUtils (see venvUtils.removeVenv.unit.test.ts and venvUtils.uvTracking.unit.test.ts), so tests should be added for:
getPythonInfo()with an environment that has an error field setfindVirtualEnvironments()encountering a broken environment- Verifying the returned broken environment has the correct properties (warning icon, error message in description/tooltip, etc.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new error handling logic in
PythonEnvTreeItemandProjectEnvironmentfor displaying broken environments lacks test coverage. The existing test suite (treeViewItems.unit.test.ts) tests context values, labels, and other properties for normal environments, but doesn't cover broken environments. Tests should be added to verify:errorfield, the context value ispythonBrokenEnvironmentinstead ofpythonEnvironment