{"record":{"id":"c765318f6a57dda6","repo":"wtfutil/wtf","slug":"panic-err-c76531","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"modules/system/system_info_windows.go","lineNumber":27,"sourceCode":")\n\ntype SystemInfo struct {\n\tProductName    string\n\tProductVersion string\n\tBuildVersion   string\n}\n\n// win11BuildNumber is the first Windows build number reported as Windows 11.\n// Windows 11 kept the \"10.0\" major.minor version, so the build number is the\n// only reliable signal Win32_OperatingSystem gives us to tell it apart from\n// Windows 10.\nconst win11BuildNumber = 22000\n\nfunc NewSystemInfo() *SystemInfo {\n\tcmd := exec.Command(\"powershell.exe\", \"(Get-CimInstance Win32_OperatingSystem).version\")\n\tout, err := cmd.Output()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tproductVersion, buildVersion := windowsProductVersion(string(out))\n\n\treturn &SystemInfo{\n\t\tProductName:    \"Windows\",\n\t\tProductVersion: productVersion,\n\t\tBuildVersion:   buildVersion,\n\t}\n}\n\n// windowsProductVersion turns the raw \"major.minor.build\" string reported by\n// Win32_OperatingSystem into a human-friendly product version and separate\n// build number. Windows 11 kept the \"10.0\" major.minor version, so the build\n// number is the only reliable signal available to distinguish it from\n// Windows 10.\nfunc windowsProductVersion(rawVersion string) (productVersion, build string) {\n\ts := strings.Split(strings.TrimSpace(rawVersion), \".\")","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/system/system_info_windows.go#L9-L45","documentation":"On Windows, NewSystemInfo shells out to PowerShell (Get-CimInstance Win32_OperatingSystem).version to read the OS build for Windows 11 detection, and panics if the command fails. This fires when powershell.exe cannot be executed or errors — missing PATH, restricted execution policy, CIM/WMI service issues, or non-Windows builds accidentally compiled with this file. It runs during construction, so it crashes startup.","triggerScenarios":"NewSystemInfo is invoked and exec.Command(\"powershell.exe\", ...).Output() returns an error: powershell.exe not on PATH, PowerShell blocked by policy or removed, WMI/CIM service (Winmgmt) stopped, or the binary built with the windows file on a non-Windows platform.","commonSituations":"Windows Server minimal installs without PowerShell, broken PATH for the service account running the app, PowerShell constrained-language/execution-policy environments, WMI repository corruption, cross-compilation mistakes including the _windows.go file on Linux.","solutions":["Confirm powershell.exe is installed and on PATH: run the same command '(Get-CimInstance Win32_OperatingSystem).version' manually","Fix PowerShell execution policy if it blocks command execution (Set-ExecutionPolicy or use -ExecutionPolicy Bypass semantics)","Ensure the WMI/Winmgmt service is running (net start winmgmt) and repair WMI if corrupted","If running as a service, give the service account access to powershell.exe and a valid PATH","If the panic message is exec format/not found on Linux, you built with the wrong GOOS — rebuild for your platform"],"exampleFix":"// before (manual check fails)\n> powershell.exe (Get-CimInstance ...)\n'powershell.exe' is not recognized\n// after\n> where.exe powershell.exe  # add its directory to PATH, or reinstall Windows PowerShell","handlingStrategy":"fallback","validationCode":"// verify the command works before the widget is constructed\nout, err := exec.Command(\"powershell.exe\", \"(Get-CimInstance Win32_OperatingSystem).version\").Output()\nif err != nil {\n    log.Printf(\"powershell unavailable, windows version detection disabled: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"func safeNewSystemInfo() (si *SystemInfo) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"system info unavailable: %v\", r)\n            si = nil // degrade gracefully\n        }\n    }()\n    return NewSystemInfo()\n}","preventionTips":["Ensure powershell.exe is on PATH for the user/service running the app","Keep the Winmgmt (WMI) service running and healthy","Don't build the windows-specific system info file for non-Windows GOOS","Prefer a build where version detection fails soft instead of panicking"],"tags":["go","panic","windows","powershell","system-info"],"backgroundTag":"powershell-execution-failed","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}