Repository navigation
fix(format-result): skip empty issue arrays to prevent ESC3 null index error - #312
Merged
Merged
Conversation
…x error - Guard Private/Format-Result.ps1 against empty arrays as well as $null - The ESC3 scan returns @() when nothing is found, which threw "Index operation failed; the array index evaluated to null." - Add Tests/Format-Result.Tests.ps1 covering $null and empty arrays in Mode 0 and Mode 1
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.
Summary
Fix
Format-ResultthrowingIndex operation failed; the array index evaluated to null.when a scan finds nothing.The ESC3 scan builds its result as
@(C1) + @(C2), which is an empty array when there are no findings. Other scans return ``.Format-Resultonly checked ` -ne `, so the empty array got through and the title lookup used a null key.Introduced by the array-optimization change in 4031b89. The guard now skips both `` and empty arrays.
Type of change
Validation
Tests/Format-Result.Tests.ps1(4 tests). Before the fix, 3 failed with the reported error. After the fix, all pass (Pester 6.2.0).Security impact
None.
Documentation impact
None.
PowerShell compatibility
No new syntax. Works on Windows PowerShell 5.1 and PowerShell 7.