From a024b03fb046ea6961a0d26acb46463c4a80d03e Mon Sep 17 00:00:00 2001 From: "DESKTOP-RTLN3BA\\$punk" Date: Wed, 10 Jun 2026 00:57:41 -0700 Subject: [PATCH] fix(install.ps1): add manual validation for Variant parameter to prevent errors during script execution --- docker/scripts/install.ps1 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docker/scripts/install.ps1 b/docker/scripts/install.ps1 index 6e973a520..23b14c3c4 100644 --- a/docker/scripts/install.ps1 +++ b/docker/scripts/install.ps1 @@ -17,10 +17,14 @@ # into the new PostgreSQL 17 stack. The user runs one command for both. # ============================================================================= +# NOTE: Do not use [ValidateSet()] (or other validation attributes without a +# valid default) on these params. When the script is piped into iex, PowerShell +# applies the attributes to variables in the caller's scope, and an empty +# $Variant fails ValidateSet with a ValidationMetadataException. Validate +# manually below instead. param( [switch]$NoWatchtower, [int]$WatchtowerInterval = 86400, - [ValidateSet("cpu", "cuda", "cuda126")] [string]$Variant, [string]$GpuCount, [switch]$Quiet @@ -40,6 +44,11 @@ $MigrationMode = $false $SetupWatchtower = -not $NoWatchtower $WatchtowerContainer = "watchtower" +if ($Variant -and $Variant -notin @("cpu", "cuda", "cuda126")) { + Write-Host "[SurfSense] ERROR: Invalid -Variant '$Variant'. Use 'cpu', 'cuda', or 'cuda126'." -ForegroundColor Red + exit 1 +} + if ($GpuCount -and $GpuCount -notmatch '^([0-9]+|all)$') { Write-Host "[SurfSense] ERROR: Invalid -GpuCount '$GpuCount'. Use a number or 'all'." -ForegroundColor Red exit 1