Don't fail VM enumeration on non-GUID compute system IDs - #36
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens WSL VM discovery on Windows by preventing HcsEnumerateComputeSystems enumeration from failing when unrelated compute systems use non-GUID IDs.
Changes:
- Deserialize compute system
IdasString(instead ofUuid) and only parse it for theOwner == "WSL"entry. - Add
#[serde(default)]to tolerate missing fields on non-WSL entries (e.g.,owner,system_type,runtime_id,state).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude broke it, Claude fixed it 😂 AI Disclaimer: this PR was created by Claude Opus 5. The diagnosis is correct, and the fix works. Unfortunately, I cannot judge the added |
`HcsEnumerateComputeSystems` returns every compute system on the host, and
not all of them use a GUID as their `Id` -- e.g. a VM named
`cowork-vm-929216c6`. Deserialising `Id` as a `Uuid` made a single such
sibling abort the whole enumeration:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value:
Custom { kind: InvalidInput, error: Error("UUID parsing failed:
invalid length: expected one of [36, 32], found 18", ...) }
so `get_wsl_vmid` failed before the WSL entry was ever looked at.
Keep `Id` as a string and only parse it as a UUID for the entry we care
about, and tolerate missing fields on the entries we don't.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
35f6eff to
a45fd63
Compare
|
It might be worth considering moving to |
|
RuntimeId is probably the corrrect ID to use, given that vsocks work only for running VMs anyway. |
HcsEnumerateComputeSystemsreturns every compute system on the host, and not all of them use a GUID as theirId. DeserialisingIdas aUuidtherefore makes one unrelated sibling abort the whole enumeration before the WSL entry is ever looked at:On the affected machine
hcsdiag listshows:cowork-vm-929216c6is the 18-characterIdfrom the error. Sinceget_wsl_vmid_by_hcsonly falls back to the registry onPermissionDenied, this is fatal rather than degraded.This keeps
Idas aStringand parses it as a UUID only for the entry we actually want (Owner == "WSL"), and tolerates missing fields on the entries we don't care about.Tested on the machine that hit the panic:
wsldhost.exenow finds the correct VM ID and connects normally.