{"record":{"id":"0984b1bcace46e7a","repo":"JanDeDobbeleer/oh-my-posh","slug":"error-unknown-registry-key-s","errorCode":null,"errorMessage":"Error, unknown registry key: '%s","messagePattern":"Error, unknown registry key: '(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/runtime/terminal_windows.go","lineNumber":167,"sourceCode":"\t\tif len(regKey) != 0 {\n\t\t\tregPath = strings.TrimSuffix(regPath, `\\`+regKey)\n\t\t}\n\t}\n\n\tvar key registry.Key\n\tswitch rootKey {\n\tcase \"HKCR\", \"HKEY_CLASSES_ROOT\":\n\t\tkey = windows.HKEY_CLASSES_ROOT\n\tcase \"HKCC\", \"HKEY_CURRENT_CONFIG\":\n\t\tkey = windows.HKEY_CURRENT_CONFIG\n\tcase \"HKCU\", \"HKEY_CURRENT_USER\":\n\t\tkey = windows.HKEY_CURRENT_USER\n\tcase \"HKLM\", \"HKEY_LOCAL_MACHINE\":\n\t\tkey = windows.HKEY_LOCAL_MACHINE\n\tcase \"HKU\", \"HKEY_USERS\":\n\t\tkey = windows.HKEY_USERS\n\tdefault:\n\t\terr := fmt.Errorf(\"Error, unknown registry key: '%s\", rootKey)\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tk, err := registry.OpenKey(key, regPath, registry.READ)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\t_, valType, err := k.GetValue(regKey, nil)\n\tif err != nil {\n\t\tlog.Error(err)\n\t\treturn nil, err\n\t}\n\n\tvar regValue *WindowsRegistryValue\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/JanDeDobbeleer/oh-my-posh/blob/0976794618c5ed95de0985dded50de1b4dc914cb/src/runtime/terminal_windows.go#L149-L185","documentation":"WindowsRegistryKeyValue splits the input on the first backslash and maps the root portion to an HKEY handle. Only HKCR, HKCC, HKCU, HKLM and HKU (long and short forms) are accepted; any other root key string hits the default branch and returns this error. Note the message has a stray unbalanced quote ('%s with no closing ').","triggerScenarios":"Calling WindowsRegistryKeyValue with an unrecognized root key such as \"HKCRU\", \"HKEY_CURRENT_CONFIG_\", lowercase \"hklm\", a typo like \"HKML\", or an empty root because the input began with a backslash.","commonSituations":"Typoed root keys in prompt configs (HKML instead of HKLM); case-sensitive matching means \"hklm\\...\" also fails; a template variable expanding to an unexpected prefix.","solutions":["Use one of the supported roots: HKCR/HKEY_CLASSES_ROOT, HKCC/HKEY_CURRENT_CONFIG, HKCU/HKEY_CURRENT_USER, HKLM/HKEY_LOCAL_MACHINE, HKU/HKEY_USERS - spelled exactly, uppercase.","Check for typos (HKML, HKLU, etc.) in the configured path.","Ensure no leading character consumed the root: input must start with the root key, not \"\\\".","If the value truly lives elsewhere, locate the correct hive (e.g. HKCU for per-user settings)."],"exampleFix":"// before\nregistry = \"HKML\\SOFTWARE\\Microsoft\\Windows\"\n\n// after\nregistry = \"HKLM\\SOFTWARE\\Microsoft\\Windows\"","handlingStrategy":"validation","validationCode":"var validRoots = []string{\"HKCR\",\"HKEY_CLASSES_ROOT\",\"HKCC\",\"HKEY_CURRENT_CONFIG\",\"HKCU\",\"HKEY_CURRENT_USER\",\"HKLM\",\"HKEY_LOCAL_MACHINE\",\"HKU\",\"HKEY_USERS\"}\nfunc validRegistryRoot(p string) bool {\n    root, _, _ := strings.Cut(p, \"\\\\\")\n    return slices.Contains(validRoots, root)\n}","typeGuard":"func hasKnownRegistryRoot(s string) bool {\n    root, _, ok := strings.Cut(s, \"\\\\\")\n    if !ok { return false }\n    switch root {\n    case \"HKCR\",\"HKCC\",\"HKCU\",\"HKLM\",\"HKU\",\n         \"HKEY_CLASSES_ROOT\",\"HKEY_CURRENT_CONFIG\",\n         \"HKEY_CURRENT_USER\",\"HKEY_LOCAL_MACHINE\",\"HKEY_USERS\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"val, err := term.WindowsRegistryKeyValue(input)\nif err != nil && strings.Contains(err.Error(), \"unknown registry key\") {\n    // correct the root key or disable the registry-dependent segment\n    return nil\n}","preventionTips":["Use the exact uppercase short forms: HKLM, HKCU, HKCR, HKCC, HKU","Double-check for transposed letters (HKML is a common typo)","Remember matching is case-sensitive: lowercase roots fail","Validate configured registry paths in CI against the accepted root list"],"tags":["windows","registry","config","input-validation"],"backgroundTag":"malformed-registry-path","analyzedSha":"0976794618c5ed95de0985dded50de1b4dc914cb","analyzedAt":"2026-08-31T23:41:19.708Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}