Skip to content

Invoke-PkProcessBatch: accept $null -Commands as an empty batch - #3

Merged
HalRiveria merged 1 commit into
mainfrom
fix/batch-null-commands
Oct 27, 2026
Merged

HalRiveria merged 1 commit into
mainfrom
fix/batch-null-commands

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong: building the command list with a foreach (as the README does) gives $null, not an empty array, when nothing matches. Invoke-PkProcessBatch then failed with "Cannot bind argument to parameter 'Commands' because it is null." [AllowEmptyCollection()] showed an empty batch was meant to work, but it doesn't cover $null.

What changed: -Commands now also has [AllowNull()], so $null runs as an empty batch and returns no results. Null entries inside the list are skipped too, instead of failing with "Cannot index into a null array".

Tested: added a harness assertion in section F that passes $null from an empty foreach. It failed before the fix (1 FAILED, 169 passed) and passes after (ALL PASSED (170 assertions)).

🤖 Generated with Claude Code

A foreach that matches nothing yields $null rather than an empty array, so
building the command list the usual way failed with a parameter-binding error
when no files matched. -Commands now allows $null, and null entries are skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria
HalRiveria merged commit 6580709 into main Oct 27, 2026
1 check passed
@HalRiveria
HalRiveria deleted the fix/batch-null-commands branch October 27, 2026 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants