From a45fd63849d1120919e20492df02daaa0e03441d Mon Sep 17 00:00:00 2001 From: Bernhard Frauendienst Date: Mon, 27 Jul 2026 21:29:21 +0200 Subject: [PATCH] Don't fail enumeration on non-GUID compute system IDs `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) --- server/src/vmcompute.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/server/src/vmcompute.rs b/server/src/vmcompute.rs index b65951d..ab5b71c 100644 --- a/server/src/vmcompute.rs +++ b/server/src/vmcompute.rs @@ -5,10 +5,15 @@ use uuid::Uuid; #[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] struct ComputeSystem { - pub id: Uuid, + // Not all compute systems use a GUID as their ID (e.g. Docker Desktop), so keep this + // a string and only parse it as a UUID for the systems we actually care about. + pub id: String, + #[serde(default)] pub system_type: String, + #[serde(default)] pub owner: String, - pub runtime_id: Uuid, + #[serde(default)] + pub runtime_id: Option, #[serde(default)] pub state: String, } @@ -80,7 +85,15 @@ fn get_wsl_vmid_by_hcs() -> std::io::Result> { let vms = enumerate_compute_systems("{}")?; for vm in vms { if vm.owner == "WSL" { - return Ok(Some(vm.id)); + // The WSL VM itself must have a GUID as its ID -- we need it to connect. Report + // a parse failure instead of pretending WSL isn't running. + let id = vm.id.parse().map_err(|err| { + std::io::Error::new( + std::io::ErrorKind::InvalidData, + format!("WSL compute system has a non-GUID ID {:?}: {}", vm.id, err), + ) + })?; + return Ok(Some(id)); } } Ok(None)