Skip to content

Don't fail VM enumeration on non-GUID compute system IDs - #36

Open
oxc wants to merge 1 commit into
nbdd0121:masterfrom
oxc:fix/non-uuid-compute-system-id
Open

Don't fail VM enumeration on non-GUID compute system IDs#36
oxc wants to merge 1 commit into
nbdd0121:masterfrom
oxc:fix/non-uuid-compute-system-id

Conversation

@oxc

@oxc oxc commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

HcsEnumerateComputeSystems returns every compute system on the host, and not all of them use a GUID as their Id. Deserialising Id as a Uuid therefore makes one unrelated sibling abort the whole enumeration before the WSL entry is ever looked at:

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", line: 1, column: 186) }',
server\src\main.rs:96:18

On the affected machine hcsdiag list shows:

2A7D902F-C90B-4F92-87CB-EBB9F7D84E99
    VM,   Running, 2A7D902F-C90B-4F92-87CB-EBB9F7D84E99, WSL

cowork-vm-929216c6
    VM,   Running, D2B9750A-3588-5FF4-A2BC-7C0F86A95EB4, cowork-vm-929216c6

cowork-vm-929216c6 is the 18-character Id from the error. Since get_wsl_vmid_by_hcs only falls back to the registry on PermissionDenied, this is fatal rather than degraded.

This keeps Id as a String and 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.exe now finds the correct VM ID and connects normally.

Copilot AI review requested due to automatic review settings July 27, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Id as String (instead of Uuid) and only parse it for the Owner == "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.

Comment thread server/src/vmcompute.rs
@oxc

oxc commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

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 serde configs.

`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>
@oxc
oxc force-pushed the fix/non-uuid-compute-system-id branch from 35f6eff to a45fd63 Compare July 27, 2026 20:01
@oxc

oxc commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

It might be worth considering moving to RuntimeId instead of Id. On my machine, this yields the same UUID, and always seems to be a UUID (also for the claude cowork container). I cannot tell whether this is guaranteed, though.

@nbdd0121

Copy link
Copy Markdown
Owner

RuntimeId is probably the corrrect ID to use, given that vsocks work only for running VMs anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants