Skip to content

Export-DbaDacPackage - Stop eating the caller loop when only ExcludeDatabase is given - #10702

Open
andreasjordan wants to merge 1 commit into
developmentfrom
fix-export-dbadacpackage-continue-escape
Open

Export-DbaDacPackage - Stop eating the caller loop when only ExcludeDatabase is given#10702
andreasjordan wants to merge 1 commit into
developmentfrom
fix-export-dbadacpackage-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

Export-DbaDacPackage rejects a call that names neither -Database nor -AllUserDatabases (only -ExcludeDatabase passes the earlier check) with Stop-Function -Continue (public/Export-DbaDacPackage.ps1:168). 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. Proven in the lab with the plain-script recipe: three calls in a foreach left the loop counter at 0 on development and at 3 with the fix.

What changed

The -Continue is dropped and an explicit return ends the block for that input, as in #10637. Nothing else changes. The check still fires before any connection is made.

Tests

New context When only ExcludeDatabase is given: three calls in a loop, asserting the loop count and the warning. Through the testing-dbatools harness: green on both editions with the fix; the plain-script proof above is the red-on-old.

created by Claude and reviewed by Andreas Jordan

🤖 Generated with Claude Code

…atabase 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.

Part of #10638

(do Export-DbaDacPackage)

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 ExcludeDatabase-only validation path now exits the command invocation without terminating its caller loop, while normal export behavior is preserved. Targeted Windows PowerShell coverage and all applicable exact-head checks pass.

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