Status: Done (2026-01-29)
Priority: High
Component: tools/pslib/wsl/lib/core.ps1
Description:
When no WSL distributions are installed, wsl-manager crashed with a type conversion error when parsing WSL verbose output that contained informational messages instead of distribution entries.
Root Cause:
The parser in Get-WslDistroList -Detailed attempted to convert the last field of every non-header line to an integer (the VERSION field). When WSL outputs informational messages like "No distributions found", the parser tried to convert non-numeric text to [int], causing the crash.
Solution:
Added validation using [int]::TryParse() before attempting to convert the version field. Lines that don't have a valid numeric version are now skipped, allowing the function to gracefully handle informational messages and return an empty array.
Changes:
- Modified
Get-WslDistroListintools/pslib/wsl/lib/core.ps1:116-130to validate version field before parsing - Added 2 new test cases in
tools/pslib/wsl/lib/core.Tests.ps1to cover edge cases with no distributions
Acceptance Criteria Met:
- No error when running
wsl-managerwith zero distributions installed - Clear message indicating no distributions are available
- Proper exit handling (gracefully returns empty array)
- Unit tests covering zero-distribution scenario
- All tests pass