omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

windows-vm: 4.0.1 migration rejects usernames the old installer allowed, stranding existing VMs with a misleading "not configured"

Open s0nspark opened this issue 3 months ago • 2 comments

System details

AMD Ryzen AI Max+ 395 (Radeon 8060S), Omarchy 4.0.1, kernel 6.18.46-1-lts, dockurr/windows

What's wrong?

4.0.1 moved the Windows VM compose from ~/.config/windows/docker-compose.yml to root-owned /var/lib/omarchy/windows/docker-compose.yml and validates every field on the root side before writing. USERNAME is validated with:

valid_username() { [[ $1 =~ ^[A-Za-z0-9_-]{1,20}$ ]]; }   # bin/omarchy-windows-vm:89

The pre-4.0.1 installer applied no validation to that field — empty fell back to docker, anything else was written verbatim:

USERNAME=$(gum input --placeholder="Username (Press enter to use default: docker)" ...)
if [[ -z $USERNAME ]]; then
  USERNAME="docker"
fi

So a VM installed with an email-style Windows account ([email protected] — what the Microsoft account sign-in prompt asks for) has a legacy compose the new code cannot migrate. write_compose exits 2 at line 140, migrate_legacy_compose returns 1 at line 358, and the VM is unreachable — while the container image and ~/.windows/data.img are completely intact.

The failure is near-undiagnosable from the CLI:

  • launch prints Windows VM not configured. Please run: omarchy-windows-vm install (line 621) — pointing the user at reinstalling a VM that already exists and works.
  • status, stop, and remove call migrate_legacy_compose 2>/dev/null || true (lines 600, 708, 724), so the one line that names the real cause (invalid username: …) is discarded outright. Those subcommands simply behave as though no VM was ever configured.

Following the suggested remedy makes it worse: install provisions a fresh VM, and it succeeds where migration failed, because the installer silently substitutes docker for an invalid username (lines 503-506). Migration rejecting what install quietly repairs is the actual defect.

Still present on master as of today.

Steps to reproduce

  1. On Omarchy < 4.0.1, omarchy-windows-vm install and enter [email protected] as the Windows username.
  2. Upgrade to 4.0.1.
  3. omarchy-windows-vm status → reports not configured, no explanation.
  4. omarchy-windows-vm launch → Windows VM not configured. Please run: omarchy-windows-vm install, despite a valid legacy compose and an intact ~/.windows/data.img.

Suggested fix

Have migrate_legacy_compose sanitize rather than reject. USERNAME is inert after install — dockurr/windows reads it only to build the unattend file during Windows setup — so falling back to docker on migration is safe and matches what install already does for the same input.

Failing that: name the offending field and value in the failure message, and stop discarding stderr in the status/stop/remove paths so the cause is at least visible.

s0nspark avatar Aug 27 '26 16:08 s0nspark

Implementing the sanitize-on-migrate path from the report.

migrate_legacy_compose will fall back to docker when the legacy USERNAME fails valid_username, matching what install already does for the same input. The elevated compose writer stays strict. RDP credentials keep the original username so an already-provisioned Windows account still logs in.

USERNAME is only consumed by dockurr/windows during first-run unattend, so rewriting it in the migrated compose does not change the guest.

Elshayib avatar Aug 27 '26 19:08 Elshayib

Checked against quattro at c352b62d6: the defect is still there. migrate_legacy_compose passes the legacy USERNAME straight to the privileged compose writer, which rejects anything failing valid_username (bin/omarchy-windows-vm:762, regex at line 139), so an email-style username fails migration and launch reports "Windows VM not configured" (line 1397). stop and status still run migration with 2>/dev/null || true (lines 1507 and 1523), so the real cause is discarded there. remove has since been changed to stop and print the error (line 1369). This was established by reading the source; no worker reproduction was run, since the fix is already open as a pull request.

#8662 fixes the username case and already says it closes this issue: it writes docker into the compose when the legacy username is invalid and keeps the original username in the credentials file, which is what RDP reads first (line 1404). Two things it does not cover, for whoever weighs it: the compose USERNAME is not inert after setup, because Omarchy writes PROTECT: "Y" and the container builds the web console's login from USERNAME and PASSWORD on every start, so the console login becomes docker (the pull request does print a notice saying so); and other legacy values can strand migration the same way, most plausibly a password longer than 64 characters, which the old installer accepted and the writer now rejects (line 763). The pull request will be reviewed on its own.

Second opinion: Codex at medium effort reviewed the source independently and agreed the defect is present and that #8662's routing fixes the username case; it raised the web-console login and the other-fields point, both checked against the source above. Its independence is not guaranteed.

This now waits on the maintainer's decision on #8662.

omarchybot avatar Oct 09 '26 04:10 omarchybot