JanDeDobbeleer/oh-my-posh · error
Error, malformed registry path: '%s'
Error message
Error, malformed registry path: '%s'
What it means
WindowsRegistryKeyValue parses an input string of the form "ROOT\Path\Key" (or "ROOT\Path\" for the Default value). strings.Cut on the first backslash must produce both a root key and a remainder; if the input contains no backslash at all, the path is malformed and the function returns this error instead of querying the registry.
Source
Thrown at src/runtime/terminal_windows.go:141
// If the path ends in "\", the "(Default)" key in that path is retrieved.
func (term *Terminal) WindowsRegistryKeyValue(input string) (*WindowsRegistryValue, error) {
defer log.Trace(time.Now(), input)
// Format:
// "HKLM\Software\Microsoft\Windows NT\CurrentVersion\EditionID"
// 1 | 2 | 3
//
// Split into:
//
// 1. Root key - extract the root HKEY string and turn this into a handle to get started
// 2. Path - open this path
// 3. Key - get this key value
//
// If 3 is "" (i.e. the path ends with "\"), then get (Default) key.
//
rootKey, regPath, found := strings.Cut(input, `\`)
if !found {
err := fmt.Errorf("Error, malformed registry path: '%s'", input)
log.Error(err)
return nil, err
}
var regKey string
if !strings.HasSuffix(regPath, `\`) {
regKey = path.Base(regPath)
if len(regKey) != 0 {
regPath = strings.TrimSuffix(regPath, `\`+regKey)
}
}
var key registry.Key
switch rootKey {
case "HKCR", "HKEY_CLASSES_ROOT":
key = windows.HKEY_CLASSES_ROOT
case "HKCC", "HKEY_CURRENT_CONFIG":
key = windows.HKEY_CURRENT_CONFIGView on GitHub (pinned to 0976794618)
Solutions
- Include the full path with backslashes, e.g. "HKLM\Software\Microsoft\Windows NT\CurrentVersion\EditionID".
- Check the config value that feeds the registry property - ensure any template variables expand to a full path.
- Verify you use backslash (\) as the separator, not forward slash.
- If you want the Default value of a key, end the path with a trailing backslash (e.g. "HKLM\Software\X\").
Example fix
// before (template/config) registry = "HKLM" // after registry = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\EditionID"
Defensive patterns
Strategy: validation
Validate before calling
func validRegistryPath(p string) bool {
return strings.Contains(p, "\\") && strings.Index(p, "\\") > 0
}
// call only if validRegistryPath(path) Type guard
func looksLikeRegistryPath(s string) bool {
i := strings.Index(s, "\\")
return i > 0
} Try / catch
val, err := term.WindowsRegistryKeyValue(input)
if err != nil && strings.Contains(err.Error(), "malformed registry path") {
// fall back to a default value or hide the segment
return defaultRegistryValue
} Prevention
- Always use backslash separators in registry paths
- Include root key + at least one path component, e.g. HKCU\Software\Key
- Verify template variables expand to full paths before render
- End the path with \ only when you want the (Default) value
When it happens
Trigger: Calling WindowsRegistryKeyValue (e.g. via a registry template property in a config) with a string lacking a backslash - like "HKLM" alone, an environment variable that resolved to a bare key name, or using forward slashes instead of backslashes.
Common situations: Config typos in a custom prompt's registry lookup; a template variable that expands to an empty or partial path; copying a registry path that uses "/" separators.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Error, unknown registry key: '%s
- unable to delete font file after registry key open error
- unable to open HKEY_CURRENT_USER
- unable to delete font file after registry key set error
- Error, no formatter for type: %d
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/84d01ae6bc601c6d.
Report an issue: GitHub.