Skip to content

Convert-DbaIndexToTable - Stop eating the caller loop when no instance is given - #10705

Open
andreasjordan wants to merge 1 commit into
developmentfrom
fix-convert-dbaindextotable-continue-escape
Open

Convert-DbaIndexToTable - Stop eating the caller loop when no instance is given#10705
andreasjordan wants to merge 1 commit into
developmentfrom
fix-convert-dbaindextotable-continue-escape

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Part of #10638, the sweep for Stop-Function -Continue outside an enclosing loop. Same shape as #10637.

Problem

Convert-DbaIndexToTable rejects a missing -SqlInstance in its begin block with Stop-Function -Continue (private/functions/Convert-DbaIndexToTable.ps1:18). No loop encloses that site inside the command, so without -EnableException the continue unwinds out of the command and consumes an iteration of whatever loop the caller runs in. The only caller, Invoke-DbaDbDataMasking, always passes SqlInstance and calls it inside its table loop, so the site cannot fire and the continue would be caught. Latent.

What changed

The -Continue is dropped and an explicit return ends the block for that input, as in #10637. Nothing else changes.

Tests

No new test: no red-on-old exists for a latent escape. The caller's test file passes on both editions through the testing-dbatools harness.

created by Claude and reviewed by Andreas Jordan

🤖 Generated with Claude Code

…e 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 <noreply@anthropic.com>

@potatoqualitee potatoqualitee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The missing-instance path now exits only the helper invocation instead of terminating the caller loop, with no change to successful conversions. The relevant command coverage passes; the failing COPY lane is unrelated Remove-DbaDatabaseSafely coverage.

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