Skip to content

Set-DbaLogin - Stop eating the caller loop on an invalid parameter combination - #10737

Merged
potatoqualitee merged 1 commit into
developmentfrom
fix-setdbalogin-continue-escape
Sep 25, 2026
Merged

potatoqualitee merged 1 commit into
developmentfrom
fix-setdbalogin-continue-escape

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Part of #10638, and its last open entry: once this merges, all 91 sites of the inventory are fixed or triaged, and the issue can be closed.

The bug

Six parameter checks in the begin block of Set-DbaLogin called Stop-Function -Continue:

  • -NewName equal to -Login
  • -Enable with -Disable
  • -GrantLogin with -DenyLogin
  • -SecurePassword with -PasswordHash
  • -PasswordHash with -PasswordMustChange
  • a -PasswordHash that is not hexadecimal

The begin block has no loop around these checks, so without -EnableException the continue escaped the command and consumed an iteration of whatever loop the caller was running. A foreach over three elements that calls Set-DbaLogin with one of these combinations completes zero iterations.

These sites waited for #10537, which touched the same file and merged on 2026-09-22.

What changed

The -Continue is dropped and every failed check in the begin block ends with return, as in #10637. The process block is already guarded by Test-FunctionInterrupt. The four checks that had no -Continue also return now, so only the first failed check warns instead of every one after it.

Tests

One new test per check (-ForEach over the six combinations): three calls in a loop, asserting the loop count and the warning. The calls never connect to the instance, because the command stops in the begin block.

Through the testing-dbatools harness: 51/51 on pwsh 7 and on Windows PowerShell 5.1. With the command change reverted, exactly the six new tests fail with Expected 3, but got 0.

created by Claude and reviewed by Andreas Jordan

🤖 Generated with Claude Code

…mbination

Six parameter checks in the begin block used Stop-Function -Continue with no
enclosing loop, so the continue escaped the command and consumed an iteration
of the caller's loop. Every failed check now stops and returns.

(do Set-DbaLogin)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@andreasjordan
andreasjordan marked this pull request as ready for review September 24, 2026 12:48

@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.

Reviewed the exact head, full patch, intended caller-loop behavior, surrounding validation/interrupt flow, tests, discussions, and CI. The begin-block validation now terminates this invocation without escaping the caller loop, preserves exception behavior, and acquires no resources before returning. The focused regressions cover all three iterations and existing real-SQL tests cover valid operations and multi-input paths. All current checks are successful except the intentionally skipped cross-platform Windows job. No material defect found.

@potatoqualitee
potatoqualitee merged commit 09a6c8d into development Sep 25, 2026
22 checks passed
@potatoqualitee
potatoqualitee deleted the fix-setdbalogin-continue-escape branch September 25, 2026 12:42
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