{"record":{"id":"36ff1fe6dab252d1","repo":"cloudflare/cloudflared","slug":"parsing-os-information-w-key-s","errorCode":null,"errorMessage":"parsing os information: %w, key=%s","messagePattern":"parsing os information: %w, key=(.+?)","errorType":"exception","errorClass":"ErrKeyNotFound","httpStatus":null,"severity":"error","filePath":"diagnostic/system_collector_utils.go","lineNumber":182,"sourceCode":"\toutput string,\n\tarchitectureKey string,\n\tosSystemKey string,\n\tosVersionKey string,\n\tosReleaseKey string,\n\tnameKey string,\n) (*OsInfo, error) {\n\tidentity := func(s string) (string, error) { return s, nil }\n\n\tkeys := []string{architectureKey, osSystemKey, osVersionKey, osReleaseKey, nameKey}\n\tpairs := findColonSeparatedPairs(\n\t\toutput,\n\t\tkeys,\n\t\tidentity,\n\t)\n\n\tarchitecture, exists := pairs[architectureKey]\n\tif !exists {\n\t\treturn nil, fmt.Errorf(\"parsing os information: %w, key=%s\", ErrKeyNotFound, architectureKey)\n\t}\n\n\tosSystem, exists := pairs[osSystemKey]\n\tif !exists {\n\t\treturn nil, fmt.Errorf(\"parsing os information: %w, key=%s\", ErrKeyNotFound, osSystemKey)\n\t}\n\n\tosVersion, exists := pairs[osVersionKey]\n\tif !exists {\n\t\treturn nil, fmt.Errorf(\"parsing os information: %w, key=%s\", ErrKeyNotFound, osVersionKey)\n\t}\n\n\tosRelease, exists := pairs[osReleaseKey]\n\tif !exists {\n\t\treturn nil, fmt.Errorf(\"parsing os information: %w, key=%s\", ErrKeyNotFound, osReleaseKey)\n\t}\n\n\tname, exists := pairs[nameKey]","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/diagnostic/system_collector_utils.go#L164-L200","documentation":"ParseWinOperatingSystemInfo parses Windows OS information from a key/value mapping (e.g. `wmic` or registry query output) and requires both the architecture key and the OS system key to be present. When either key is absent from the parsed pairs it returns ErrKeyNotFound wrapped in this message with the offending key name, so the Windows OS info cannot be assembled.","triggerScenarios":"Calling ParseWinOperatingSystemInfo (directly or via collectOSInformation on Windows) when the underlying command/query output lacks `architectureKey` or `osSystemKey` — e.g. wmic/registry output in a different language, a stripped-down Windows image, or output redirection failing so pairs is empty or partial.","commonSituations":"Non-English Windows locales renaming Caption/OSArchitecture values, wmic being deprecated/removed on newer Windows builds so the query returns nothing, running with insufficient privileges to read the registry/WMI, or parsing output whose format changed between Windows versions.","solutions":["Log/inspect the parsed `pairs` map to see which keys actually came back and compare against architectureKey/osSystemKey.","Replace deprecated wmic-based collection with PowerShell (`Get-CimInstance Win32_OperatingSystem`) or direct registry reads that reliably expose the expected values.","Run the collector with sufficient privileges so WMI/registry queries return complete data.","Handle locale differences: query values by stable property/registry names (not localized display strings) or set the query to invariant culture/English output."],"exampleFix":"// before\npairs, err := buildKV(output, keys, identity)\ninfo, err := diagnostic.ParseWinOperatingSystemInfo(output)\n// after\npairs, err := buildKV(output, keys, identity)\nif err != nil {\n\treturn fmt.Errorf(\"os info query failed: %w\", err)\n}\nfor _, k := range []string{architectureKey, osSystemKey} {\n\tif _, ok := pairs[k]; !ok {\n\t\treturn fmt.Errorf(\"missing os info key %q in: %v\", k, pairs)\n\t}\n}\ninfo, err := diagnostic.ParseWinOperatingSystemInfo(output)","handlingStrategy":"validation","validationCode":"func validateOsInfoPairs(pairs map[string]string, required ...string) error {\n\tfor _, k := range required {\n\t\tif _, ok := pairs[k]; !ok {\n\t\t\treturn fmt.Errorf(\"missing required os info key: %s\", k)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"info, err := diagnostic.ParseWinOperatingSystemInfo(output)\nvar target error = diagnostic.ErrKeyNotFound\nif errors.Is(err, target) {\n\tlog.Warn().Msg(\"Windows OS info incomplete; skipping OS diagnostics\")\n} else if err != nil {\n\treturn fmt.Errorf(\"windows os info parse failed: %w\", err)\n}","preventionTips":["Prefer CIM/PowerShell or registry queries with stable property names over locale-dependent display strings.","Run collection with privileges sufficient to read WMI/registry.","Log the raw key/value pairs when keys are missing to diagnose format drift between Windows versions.","Verify wmic availability (deprecated on recent Windows) before relying on wmic-based collection."],"tags":["windows","parsing","diagnostics","os-information"],"backgroundTag":"missing-config-key","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}