From 92fc8a09fc76505dca1f847c31ae75c6ca3ce266 Mon Sep 17 00:00:00 2001 From: Justin Emerson Date: Fri, 24 Jul 2026 16:12:28 -0700 Subject: [PATCH] fix: replace Mandatory prompt with explicit throw in Get-PfbSsotVersionMapUri [Parameter(Mandatory)] on -BaseUri/-TopicId caused PowerShell's binder to prompt interactively for the missing value when run in a real interactive host, instead of throwing -- hanging a real terminal session rather than failing fast. Tests/PfbVersionMapTools.Tests.ps1's "requires -X" assertions only passed reliably in non-interactive hosts (CI) by accident. Replace with optional params + explicit IsNullOrEmpty checks that always throw deterministically regardless of host interactivity. Existing tests pass unchanged. Unrelated to #33's query-param migration but found while live-testing that work locally in an interactive terminal. --- tools/lib/PfbVersionMapTools.ps1 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/lib/PfbVersionMapTools.ps1 b/tools/lib/PfbVersionMapTools.ps1 index ad19449..9aa198b 100644 --- a/tools/lib/PfbVersionMapTools.ps1 +++ b/tools/lib/PfbVersionMapTools.ps1 @@ -26,15 +26,21 @@ function Get-PfbSsotVersionMapUri { #> [CmdletBinding()] param( - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] + [Parameter()] [string]$BaseUri, - [Parameter(Mandatory)] - [ValidateNotNullOrEmpty()] + [Parameter()] [string]$TopicId ) + # Deliberately not [Parameter(Mandatory)]: PowerShell's mandatory-parameter binder + # prompts interactively for a missing value when the host supports it (a real + # console), rather than throwing - which would hang a script or corrupt a terminal + # session instead of failing fast. Explicit checks guarantee a deterministic throw + # in every host. + if ([string]::IsNullOrEmpty($BaseUri)) { throw [System.Management.Automation.PSArgumentException]::new('BaseUri is required.', 'BaseUri') } + if ([string]::IsNullOrEmpty($TopicId)) { throw [System.Management.Automation.PSArgumentException]::new('TopicId is required.', 'TopicId') } + return "$BaseUri/v1/topics/$TopicId/content" }