From f5fca0ab56843c8769d491c6391675f9e66c537b Mon Sep 17 00:00:00 2001 From: Andreas Jordan Date: Sat, 12 Sep 2026 15:25:44 +0200 Subject: [PATCH] Convert-DbaIndexToTable - Stop eating the caller loop when no instance is given Stop-Function -Continue runs PowerShell's continue. No loop encloses this call site inside the command, so the continue unwound out of the command and consumed an iteration of whatever loop the caller runs in: a user's foreach silently skipped an element, and Pester's runner corrupted. The escape only bites the non-EnableException path; with EnableException Stop-Function throws before it gets there. Latent: the only caller, Invoke-DbaDbDataMasking, always passes SqlInstance and calls it inside its table loop, so the site could not fire and the continue would have been caught. No red-on-old test exists for a latent escape. Part of #10638 (do Convert-DbaIndexToTable) Co-Authored-By: Claude Fable 5.1 --- private/functions/Convert-DbaIndexToTable.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/private/functions/Convert-DbaIndexToTable.ps1 b/private/functions/Convert-DbaIndexToTable.ps1 index ccde0c4062f9..479951b3e02a 100644 --- a/private/functions/Convert-DbaIndexToTable.ps1 +++ b/private/functions/Convert-DbaIndexToTable.ps1 @@ -15,7 +15,10 @@ function Convert-DbaIndexToTable { begin { # Some parameter checking if (-not $SqlInstance) { - Stop-Function -Message "Please enter an instance" -Continue + # No -Continue here: this block has no enclosing loop, so the continue would escape the command + # and eat an iteration of whatever loop the caller runs in (#10638). + Stop-Function -Message "Please enter an instance" + return } # Get the database