Skip to content

Fix Windows UTF-8 stdout crash and Win11 OS-name label in self-check#1

Open
luisassardo wants to merge 1 commit into
mainfrom
fix/windows-utf8-and-os-label
Open

Fix Windows UTF-8 stdout crash and Win11 OS-name label in self-check#1
luisassardo wants to merge 1 commit into
mainfrom
fix/windows-utf8-and-os-label

Conversation

@luisassardo

Copy link
Copy Markdown
Owner

What changed

Two Windows-specific fixes surfaced by the first run of the checks on real Windows 11 hardware.

1. engine/checks_windows/cat01_updates.py — misleading OS label in WIN-CAT01-001 evidence

The OS-version check derived its title from the build number (correct), but the evidence field printed the raw registry ProductName. On Windows 11 that key still literally reads Windows 10 Pro — a long-standing Microsoft quirk; HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName was never updated for Win11. The report therefore showed a confusing Windows 10 Pro line on Win11 devices.

Now the evidence derives the OS name from the build number (>= 22000 ⇒ "Windows 11") while preserving the SKU suffix (Pro, Home, …) recovered from ProductName. Evidence reads:

Windows 11 Pro
Version: 25H2
Build: 26200.8117

2. engine/selfcheck.py — UTF-8 stdout crash on Windows

On Windows, sys.stdout defaults to the legacy cp1252 codec, which cannot encode the Unicode in findings (e.g. the arrow), crashing json.dump. main() now forces stdout/stderr to UTF-8. The JSON-on-stdout contract requires UTF-8, and macOS/Linux are already UTF-8 so the reconfigure call is a no-op there.

Why

Both bugs only manifest on Windows; the OS-label one produces a confusing report, the UTF-8 one is a hard crash.

Verification

python -m engine.selfcheck --pretty on Windows 11 (build 26200.8117): exits 0, returns 24 findings, and WIN-CAT01-001 now shows:

  • Title: Windows 11 build 26200.8117 is on a supported version (PASS)
  • Evidence: Windows 11 Pro / Version: 25H2 / Build: 26200.8117

Reviewer notes

  • The ProductName SKU is preserved; if ProductName is empty or just "Windows", evidence falls back cleanly to Windows 11 with no dangling suffix.
  • An unrelated src-tauri/Cargo.toml line-ending (LF→CRLF) change in the working tree was intentionally left out — it has no content diff.

🤖 Generated with Claude Code

First run of the Windows checks on real hardware surfaced two issues:

- engine/selfcheck.py: on Windows, sys.stdout defaults to the legacy
  cp1252 codec and json.dump(..., ensure_ascii=False) crashed on the
  Unicode in findings (e.g. the right-arrow character). Force stdout and
  stderr to UTF-8 in main(); no-op on macOS/Linux. The JSON-on-stdout
  contract requires UTF-8, and the Tauri shell consumes this stdout.

- engine/checks_windows/cat01_updates.py: derive the display OS name from
  the build number instead of registry ProductName, which still reads
  'Windows 10 Pro' on Windows 11. Evidence now shows 'Windows 11 Pro'.

Validated on Windows 11 (build 26200.8117): selfcheck exits 0, 24
findings, and the report/PDF/.age export all work in the Tauri app.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant