Background
PR #23 added [ValidateNotNullOrEmpty()] to the $Task parameter in build.ps1:
[ValidateNotNullOrEmpty()]
[string[]]$Task = 'default',
During the cross-repo propagation sweep of this style change (SrrDBAutomationToolkit#20, YouTubeMusicPS#22, ScheduledTasksManager#41, PlexAutomationToolkit#54, ReScenePS#17), Copilot's PR reviewer on ScheduledTasksManager#41 flagged that [ValidateNotNullOrEmpty()] on a [string[]] parameter:
- ✅ rejects
$null
- ✅ rejects
@() (empty collection)
- ❌ does not reject
@('') — ./build.ps1 -Task '' binds as a single-element array containing an empty string and slips past validation
The cross-repo sweep was merged as-is (matching the canonical template) with this gap acknowledged. Tightening the validator at the source means future template-derived repos get the better version for free, and a follow-up propagation PR can clean up the consumer repos.
Proposed fix
Replace the single-attribute validator with a ValidateScript that rejects per-element null/empty/whitespace. Sketch:
[ValidateScript({
foreach ($t in $_) {
if ([string]::IsNullOrWhiteSpace($t)) {
throw "-Task values cannot be null, empty, or whitespace."
}
}
$true
})]
[string[]]$Task = 'default',
Alternative: drop the [string[]] and use [string]$Task if multiple tasks aren't actually a supported use case — but Invoke-psake -TaskList does accept arrays, so the array form should probably stay.
Verification
- Default invocation (
./build.ps1) still resolves $Task = 'default'.
./build.ps1 -Task '' fails fast with a parameter-validation error.
./build.ps1 -Task @('Build', '') fails fast.
./build.ps1 -Task @() and ./build.ps1 -Task $null still fail fast (existing behavior preserved).
Downstream propagation
After the template lands, consumer repos that just received the basic validator need a follow-up PR:
- SrrDBAutomationToolkit
- YouTubeMusicPS
- ScheduledTasksManager
- PlexAutomationToolkit
- ReScenePS
JsmOperations already has the basic [ValidateNotNullOrEmpty()] form and should be swept the same way.
Origin
Surfaced 2026-05-11 by Copilot review on ScheduledTasksManager#41 during the build.ps1 validator sweep. Filed here so the fix lives in the template; cross-repo cleanup follows once the template-side fix is in.
Background
PR #23 added
[ValidateNotNullOrEmpty()]to the$Taskparameter inbuild.ps1:During the cross-repo propagation sweep of this style change (SrrDBAutomationToolkit#20, YouTubeMusicPS#22, ScheduledTasksManager#41, PlexAutomationToolkit#54, ReScenePS#17), Copilot's PR reviewer on ScheduledTasksManager#41 flagged that
[ValidateNotNullOrEmpty()]on a[string[]]parameter:$null@()(empty collection)@('')—./build.ps1 -Task ''binds as a single-element array containing an empty string and slips past validationThe cross-repo sweep was merged as-is (matching the canonical template) with this gap acknowledged. Tightening the validator at the source means future template-derived repos get the better version for free, and a follow-up propagation PR can clean up the consumer repos.
Proposed fix
Replace the single-attribute validator with a
ValidateScriptthat rejects per-element null/empty/whitespace. Sketch:Alternative: drop the
[string[]]and use[string]$Taskif multiple tasks aren't actually a supported use case — butInvoke-psake -TaskListdoes accept arrays, so the array form should probably stay.Verification
./build.ps1) still resolves$Task = 'default'../build.ps1 -Task ''fails fast with a parameter-validation error../build.ps1 -Task @('Build', '')fails fast../build.ps1 -Task @()and./build.ps1 -Task $nullstill fail fast (existing behavior preserved).Downstream propagation
After the template lands, consumer repos that just received the basic validator need a follow-up PR:
JsmOperations already has the basic
[ValidateNotNullOrEmpty()]form and should be swept the same way.Origin
Surfaced 2026-05-11 by Copilot review on ScheduledTasksManager#41 during the build.ps1 validator sweep. Filed here so the fix lives in the template; cross-repo cleanup follows once the template-side fix is in.