{"record":{"id":"7f37e61b7fc28c5b","repo":"itsfatduck/optimizerDuck","slug":"registry-verify-failed-at-path-name-could-not-read-the-value","errorCode":null,"errorMessage":"Registry verify failed at {Path}:{Name}: could not read the value.","messagePattern":"Registry verify failed at (.+?):(.+?): could not read the value\\.","errorType":"exception","errorClass":"StepExecutionException","httpStatus":null,"severity":"error","filePath":"optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs","lineNumber":259,"sourceCode":"            Action = Enum.Parse<RevertAction>(data[nameof(Action)]!.ToString()),\n            Path = data[nameof(Path)]!.ToString(),\n            Name = data[nameof(Name)]?.ToObject<string>(),\n            Value = value,\n            Kind = kind,\n            CreatedSubKeys = createdSubKeys,\n            SubSteps = subSteps,\n        };\n    }\n\n    private void VerifyRestore(OpCall call)\n    {\n        switch (Action)\n        {\n            case RevertAction.RestorePrevious when Value != null:\n            {\n                var item = new RegistryItem(Path, Name!);\n                if (!RegistryService.TryReadValue(item, out var actual, call.Logger))\n                    throw new StepExecutionException(\n                        $\"Registry verify failed at {Path}:{Name}: could not read the value.\",\n                        null\n                    );\n                if (!ValuesEqual(actual, Value, Kind))\n                    throw new StepExecutionException(\n                        $\"Registry verify failed at {Path}:{Name}: expected '{Value}', actual '{actual}'\",\n                        null\n                    );\n                break;\n            }\n            case RevertAction.NoPreviousValue:\n            case RevertAction.RestorePrevious:\n            {\n                // a failed read is not \"absent\".\n                if (\n                    !RegistryService.TryReadValue(\n                        new RegistryItem(Path, Name!),\n                        out var actual,","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/itsfatduck/optimizerDuck/blob/36acf585ae122a09f0e29eb4acedfaf94e81c0de/optimizerDuck/Domain/Revert/Steps/RegistryRevertStep.cs#L241-L277","documentation":"Thrown by RegistryRevertStep.VerifyRestore when a read-back of a restored registry value fails entirely (TryReadValue returns false). After writing the original value back during revert, the step re-reads it to prove the restore took effect; if the value cannot be read at all, the revert is reported as failed.","triggerScenarios":"RevertAction.RestorePrevious with a non-null Value, followed by TryReadValue on {Path}:{Name} returning false — key deleted between write and verify, access denied on the key, or the write silently not landing.","commonSituations":"Security software or another process deleting the key right after the restore; corrupted Path/Name in the revert JSON (e.g. truncated or wrong root prefix); 32/64-bit registry view mismatch redirecting the read to a WOW6432Node key that does not exist.","solutions":["Check that the key Path exists and the value Name is readable in regedit (or via PowerShell Get-ItemProperty).","Verify the revert JSON's Path/Name/Kind fields match the actual registry location, including correct WOW64 view.","Re-run the revert elevated; access-denied reads report as unreadable.","Check logs (call.Logger output) from RegistryService.TryReadValue for the underlying Win32 error.","Restore the value manually and delete the revert file."],"exampleFix":"// before\nthrow new StepExecutionException($\"Registry verify failed at {Path}:{Name}: could not read the value.\", null);\n// after: pre-check before throwing\nif (!RegistryService.KeyExists(new RegistryItem(Path)))\n    logger.LogWarning(\"Key {Path} missing during verify; treating as unrecoverable\", Path);","handlingStrategy":"try-catch","validationCode":"// before revert\nbool keyReadable = RegistryService.KeyExists(new RegistryItem(step.Path));\nif (!keyReadable) logger.LogWarning(\"Key {Path} unreadable before revert\", step.Path);","typeGuard":"bool IsRestorable(RegistryRevertStep s) => s.Action == RevertAction.RestorePrevious && s.Value != null && !string.IsNullOrWhiteSpace(s.Path);","tryCatchPattern":"try { await step.ExecuteAsync(shell, logger); }\ncatch (StepExecutionException ex) when (ex.Message.Contains(\"could not read the value\"))\n{\n    logger.LogError(\"Restore lost: value unreadable at revert time. Check key permissions/WOW64 view.\");\n}","preventionTips":["Keep revert JSON Path/Kind consistent with the actual registry value kind.","Avoid 32/64-bit view mismatches; test under the same bitness the app writes with.","Run elevated so verify reads are not denied."],"tags":["registry","verify","revert","windows"],"backgroundTag":"file-read-failed","analyzedSha":"36acf585ae122a09f0e29eb4acedfaf94e81c0de","analyzedAt":"2026-09-13T08:30:13.845Z","contentChangedAt":"2026-09-13T08:30:13.845Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}