Skip to content

Add support for error field from PET to surface broken environments in UI #1178

@karthiknadig

Description

@karthiknadig

Problem

The PET (Python Environment Tools) server now reports broken/invalid environments with an error field in the PythonEnvironment struct (e.g., detecting broken symlinks, missing Python executables). However, the VS Code extension doesn't receive or display this information to users.

Current Behavior

  1. Missing error field in NativeEnvInfo interface (nativePythonFinder.ts):

    export interface NativeEnvInfo {
        displayName?: string;
        name?: string;
        executable?: string;
        kind?: NativePythonEnvironmentKind;
        version?: string;
        prefix?: string;
        manager?: NativeEnvManagerInfo;
        project?: string;
        arch?: 'x64' | 'x86';
        symlinks?: string[];
        // Missing: error?: string;
    }
  2. Broken environments silently skipped (venvUtils.ts):

    for (const e of envs) {
        if (!(e.prefix && e.executable && e.version)) {
            log.warn(`Invalid venv environment: ${JSON.stringify(e)}`);
            continue;  // Silently skips - users never see broken envs
        }

Impact

  • Users cannot see or diagnose broken virtual environments
  • Environments with broken symlinks (e.g., base Python was uninstalled) silently disappear from the list
  • No actionable feedback to help users fix the issue

Expected Behavior

  1. Add error?: string field to NativeEnvInfo interface
  2. Display broken environments in the Environments view with a warning indicator
  3. Show the error message in tooltip/details so users understand what's wrong
  4. Allow users to remove/recreate broken environments

Proposed UI

  • Show broken environments with a warning icon (⚠️) or dimmed appearance
  • Tooltip should show: "This environment has issues: {error message}"
  • Right-click menu could offer "Remove broken environment" option

Technical Changes Needed

  1. Add error field to NativeEnvInfo interface
  2. Update findVirtualEnvironments() to include environments with errors
  3. Update PythonEnvironmentInfo API type if needed
  4. Update environment tree view to handle error states
  5. Add appropriate UI styling for broken environments

Related

  • PET already detects and reports these errors from try_environment_from_venv_dir() in pet-venv/src/lib.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions