{"record":{"id":"a22bb9fc095e8a82","repo":"ramensoftware/windhawk","slug":"missing-registrykey-value","errorCode":null,"errorMessage":"Missing RegistryKey value","messagePattern":"Missing RegistryKey value","errorType":"exception","errorClass":"std::runtime_error","httpStatus":null,"severity":"error","filePath":"src/windhawk/app/storage_manager.cpp","lineNumber":233,"sourceCode":"    enginePath = PathFromStorage(storage, L\"EnginePath\", folderPath);\n    uiPath = PathFromStorage(storage, L\"UIPath\", folderPath, /*optional=*/true);\n    compilerPath = PathFromStorage(storage, L\"CompilerPath\", folderPath,\n                                   /*optional=*/true);\n    appDataPath = PathFromStorage(storage, L\"AppDataPath\", folderPath);\n\n    if (!std::filesystem::is_directory(appDataPath)) {\n        std::error_code ec;\n        std::filesystem::create_directories(appDataPath, ec);\n    }\n\n    portableStorage = storage.GetInt(L\"Portable\").value_or(0);\n    if (portableStorage) {\n        settingsPath = IniFilePath{appDataPath / L\"settings.ini\"};\n    } else {\n        std::wstring registryKey =\n            storage.GetString(L\"RegistryKey\").value_or(L\"\");\n        if (registryKey.empty()) {\n            throw std::runtime_error(\"Missing RegistryKey value\");\n        }\n\n        auto firstBackslash = registryKey.find(L'\\\\');\n        if (firstBackslash == registryKey.npos) {\n            throw std::runtime_error(\"Invalid RegistryKey value\");\n        }\n\n        HKEY hkey;\n\n        std::wstring baseKey = registryKey.substr(0, firstBackslash);\n        if (baseKey == L\"HKEY_CURRENT_USER\" || baseKey == L\"HKCU\") {\n            hkey = HKEY_CURRENT_USER;\n        } else if (baseKey == L\"HKEY_USERS\" || baseKey == L\"HKU\") {\n            hkey = HKEY_USERS;\n        } else if (baseKey == L\"HKEY_LOCAL_MACHINE\" || baseKey == L\"HKLM\") {\n            hkey = HKEY_LOCAL_MACHINE;\n        } else {\n            throw std::runtime_error(\"Unsupported RegistryKey value\");","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/ramensoftware/windhawk/blob/61d99ed8e182e1af1b60109612b6763ad1b4b74e/src/windhawk/app/storage_manager.cpp#L215-L251","documentation":"In non-portable mode, StorageManager's constructor reads the \"RegistryKey\" value that says where settings live in the registry. If that value is empty or absent, the manager cannot determine its settings location and throws immediately.","triggerScenarios":"Constructing StorageManager with portableStorage == false when storage.GetString(L\"RegistryKey\") returns nothing or an empty string.","commonSituations":"Registry value deleted by cleanup tools or manual edits; migration between portable and installed mode leaving the key unset; corrupted bootstrap storage.","solutions":["Set the RegistryKey value (e.g. HKEY_CURRENT_USER\\Software\\Windhawk) in the bootstrap storage","Repair/reinstall Windhawk so the installer writes the default RegistryKey","If portable use is intended, enable portable mode so the INI path branch is taken instead","Back up and restore registry values if group policy or scripts strip them"],"exampleFix":"// before: bootstrap storage\n\"RegistryKey\": \"\"\n// after\n\"RegistryKey\": \"HKEY_CURRENT_USER\\\\Software\\\\Windhawk\"","handlingStrategy":"validation","validationCode":"std::wstring key = storage.GetString(L\"RegistryKey\").value_or(L\"\");\nif (key.empty()) { repairBootstrapStorage(); }","typeGuard":null,"tryCatchPattern":"try {\n    StorageManager sm(/*portableStorage=*/false);\n} catch (const std::exception& e) {\n    Log(L\"storage init failed: %hs\", e.what());\n}","preventionTips":["Don't strip the RegistryKey value when cleaning the registry","Use portable mode explicitly instead of deleting registry config","Back up bootstrap storage before mode migrations"],"tags":["registry","config","cpp","windows"],"backgroundTag":"missing-required-config-field","analyzedSha":"61d99ed8e182e1af1b60109612b6763ad1b4b74e","analyzedAt":"2026-09-12T14:02:41.115Z","contentChangedAt":"2026-09-12T14:02:41.115Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}