Fix Compare-InstallerSnapshots.ps1 StrictMode crash on empty UninstallEntries - #1008
Open
johnml1135 wants to merge 2 commits into
Open
Fix Compare-InstallerSnapshots.ps1 StrictMode crash on empty UninstallEntries#1008johnml1135 wants to merge 2 commits into
johnml1135 wants to merge 2 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1008 +/- ##
==========================================
+ Coverage 32.97% 40.33% +7.35%
==========================================
Files 1202 1542 +340
Lines 278291 365073 +86782
Branches 37166 40233 +3067
==========================================
+ Hits 91776 147237 +55461
- Misses 158649 188551 +29902
- Partials 27866 29285 +1419 🚀 New features to boost your workflow:
|
Compare-InstallerSnapshots.ps1 runs under Set-StrictMode -Version
Latest and read $p.DisplayName directly for every item in a
snapshot's UninstallEntries. When a snapshot has no uninstall
entries, Collect-InstallerSnapshot serializes the empty list as {}
(a Windows PowerShell ConvertTo-Json quirk), so ConvertFrom-Json
yields a single property-less object. Reading .DisplayName on it
threw "The property 'DisplayName' cannot be found on this object",
aborting the diff (observed after a silent MSI install whose
before-snapshot had 0 entries).
Extract DisplayName via a helper that tolerates $null, a single
unwrapped object, and the empty {} object, skipping entries without
a usable DisplayName.
Verified: re-running against the real before/after snapshots that
triggered the crash now completes (exit 0) and writes
diff-before-vs-after-install.txt.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The comment above Get-DisplayNameList restated the function's name, named Collect-InstallerSnapshot as a cross-file provenance pointer, and ran well past the repo's 200-character implementation-comment budget. Trim it to the single non-obvious fact a reader needs: which input shapes StrictMode would otherwise throw on.
johnml1135
force-pushed
the
fix/compare-installer-snapshots-strictmode
branch
from
August 14, 2026 07:03
b256892 to
1051486
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compare-InstallerSnapshots.ps1crashed underSet-StrictModewhenever abefore/after snapshot had zero
UninstallEntries.Collect-InstallerSnapshotserializes an empty list as
{}(a Windows PowerShellConvertTo-Jsonquirk), and the script read
.DisplayNamedirectly off that property-lessobject, which throws under strict mode. This surfaced while gathering
installer evidence: a silent MSI install whose before-snapshot legitimately
had 0 uninstall entries made the diff tool abort instead of producing a
report.
The fix extracts
DisplayNamethrough a newGet-DisplayNameListhelperthat tolerates
$null, a single unwrapped object, and the empty{}object, skipping any entry without a usable
DisplayName. Everything elseabout the diff -- registry and file comparison -- is untouched.
Where to look
Get-DisplayNameList(scripts/Agent/Compare-InstallerSnapshots.ps1) --the null/empty/unwrapped-object handling is the whole fix.
UninstallEntries) now gothrough the same helper, so the two snapshots can't drift in how they
handle a missing entry.
Deliberately not here
Collect-InstallerSnapshot's{}-for-empty-list serialization isunchanged; hardening the producer to always emit
[]is a separate,reasonable follow-up.
Verification
{}UninstallEntries(the exact shape that crashed): exits 0, produces theexpected diff.
gitlint --ignore body-is-missing --commits origin/main..HEAD-- clean.Reading this a year from now -- start here
The one thing worth knowing beyond the pitch above: the
{}-for-empty-listquirk lives in
Collect-InstallerSnapshot's JSON serialization, not in thisscript. This script tolerates it rather than fixing the producer, so any
other consumer of a snapshot file needs the same tolerance.
Preflight review details
See
.review/summary.mdon the reviewing machine for the full pass:no contract/API impact, no open findings, verification steps as listed
above.
This change is