Problem
Test and validation gaps that allow silent drift:
- Wrapper parity.
Windows-PATH-Repair.ps1 duplicates the canonical script's parameter list and forwards via @PSBoundParameters. If Windows-Path-Repair-Full.ps1 gains a parameter, the wrapper silently won't accept or forward it (it already intentionally omits -NoExecute). No test asserts the relationship.
- Backup functions.
Save-PathBackup/Read-PathBackup round-trip is untested, as are Read-PathBackup's rejection paths (missing file, invalid JSON, wrong SchemaVersion/missing properties) and Get-VerifiedDirectoryCandidates. The double-failure path in Invoke-PathUpdate (write fails AND rollback fails → manual-restore message) is also uncovered.
- Restore validation is too weak.
Read-PathBackup (~line 245) validates property presence but not that MachinePath/UserPath are scalar strings. A hand-edited backup whose value is an array or object gets [string]-cast at ~lines 431–432 into garbage like System.Object[], which Test-PathValueSafety will not catch (it only checks length/empty). Malformed values should be rejected at read time.
Proposed fix
Read-PathBackup: reject backups whose MachinePath/UserPath are not strings (null is acceptable only if explicitly allowed), with a clear error naming the offending property.
- Add Pester tests:
- Wrapper's parameter set equals the canonical script's minus an explicit allowlist (
NoExecute).
- Round-trip
Save-PathBackup → Read-PathBackup under $TestDrive (redirect the backup dir or extract a -BackupDirectory parameter to make it testable).
- Rejection cases for
Read-PathBackup: missing file, invalid JSON, wrong schema version, missing properties, non-string values (array/object/number).
- Rollback-also-fails case for
Invoke-PathUpdate using the injectable scriptblock seams.
Problem
Test and validation gaps that allow silent drift:
Windows-PATH-Repair.ps1duplicates the canonical script's parameter list and forwards via@PSBoundParameters. IfWindows-Path-Repair-Full.ps1gains a parameter, the wrapper silently won't accept or forward it (it already intentionally omits-NoExecute). No test asserts the relationship.Save-PathBackup/Read-PathBackupround-trip is untested, as areRead-PathBackup's rejection paths (missing file, invalid JSON, wrongSchemaVersion/missing properties) andGet-VerifiedDirectoryCandidates. The double-failure path inInvoke-PathUpdate(write fails AND rollback fails → manual-restore message) is also uncovered.Read-PathBackup(~line 245) validates property presence but not thatMachinePath/UserPathare scalar strings. A hand-edited backup whose value is an array or object gets[string]-cast at ~lines 431–432 into garbage likeSystem.Object[], whichTest-PathValueSafetywill not catch (it only checks length/empty). Malformed values should be rejected at read time.Proposed fix
Read-PathBackup: reject backups whoseMachinePath/UserPathare not strings (null is acceptable only if explicitly allowed), with a clear error naming the offending property.NoExecute).Save-PathBackup→Read-PathBackupunder$TestDrive(redirect the backup dir or extract a-BackupDirectoryparameter to make it testable).Read-PathBackup: missing file, invalid JSON, wrong schema version, missing properties, non-string values (array/object/number).Invoke-PathUpdateusing the injectable scriptblock seams.