Get-LoginPasswordHash - Stop eating the caller loop when the hash query fails - #10704
Open
andreasjordan wants to merge 1 commit into
Open
Get-LoginPasswordHash - Stop eating the caller loop when the hash query fails#10704andreasjordan wants to merge 1 commit into
andreasjordan wants to merge 1 commit into
Conversation
…ry fails 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, Sync-DbaLoginPassword, calls it inside its login loop, so the continue was caught there - but it bypassed the caller's null-hash handling and the return that follows the call never ran. No red-on-old test exists for a latent escape; the return after the call now runs as written. Part of #10638 (do Get-LoginPasswordHash) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
potatoqualitee
approved these changes
Sep 13, 2026
potatoqualitee
left a comment
Member
There was a problem hiding this comment.
The failure path now returns from the helper scope rather than terminating the caller loop, while successful hash retrieval remains unchanged. The control-flow reproduction completes all caller iterations and the current CI checks are green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #10638, the sweep for
Stop-Function -Continueoutside an enclosing loop. Same shape as #10637.Problem
Get-LoginPasswordHashreports a failed hash query from its inner catch, followed by areturnthat never ran withStop-Function -Continue(private/functions/Get-LoginPasswordHash.ps1:71). No loop encloses that site inside the command, so without-EnableExceptionthecontinueunwinds out of the command and consumes an iteration of whatever loop the caller runs in. The only caller,Sync-DbaLoginPassword, calls it inside its login loop, so the escape was caught there - but it bypassed the caller's own handling of a missing hash and thereturnafter the call. Latent as far as a user is concerned.What changed
The
-Continueis dropped; thereturnthat follows now runs as written.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