Expand-DbaDbLogFile - Stop eating the caller loop when the log file processing fails - #10703
Expand-DbaDbLogFile - Stop eating the caller loop when the log file processing fails#10703andreasjordan wants to merge 2 commits into
Conversation
…rocessing 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. The message of that catch also read a variable that does not exist ($_InvocationInfo), so the line number was always empty; it is $_.InvocationInfo now. The catch wraps the whole process block and its inner failures are caught by the per-database loop, so no lab trigger for the outer catch was found; the fix mirrors the pattern of #10637. Part of #10638 (do Expand-DbaDbLogFile) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
CI showed the mocked "TargetVlfCount planning" test failing once the escaping continue was gone: the test had never run past the command call, because the catch's continue ended the It block before its assertions. The mocked run always ended in that catch, for three reasons in a row: $Databases.Count was null for a single PSCustomObject (the three filter assignments now wrap their result in @(), harmless for SMO), the Pester mock of Measure-DbaDbVirtualLogFile kept the DbaInstanceParameter binding that rejects the mocked server (now a plain function like the other stubs in the file), and the Select-DefaultView stub had no -ExcludeProperty. Part of #10638 (do Expand-DbaDbLogFile) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
The SINGLE 1/5 failure is the same kind of finding as on #10701: a test that had never really run. What failed. The mocked unit test "Uses a smaller final growth when that keeps VLFs within TargetVlfCount" expects one result and got none. On Why the mocked run failed, three gaps in a row (found by asserting on the collected warnings first, so Pester prints them):
The lab runs behind this PR used the IntegrationTests tag only, which is why the unit test was not caught before CI; the full file now runs green on both editions here: 5/5 on PowerShell 7 and 5/5 on Windows PowerShell 5.1, unit and integration tags together. Created by Claude and reviewed by Andreas Jordan. |
potatoqualitee
left a comment
There was a problem hiding this comment.
The log-file failure path now returns from the helper scope instead of terminating the caller loop, preserving successful expansion behavior and multi-input processing. All applicable exact-head CI checks pass.
Part of #10638, the sweep for
Stop-Function -Continueoutside an enclosing loop. Same shape as #10637.Problem
Expand-DbaDbLogFilereports a failed run from the catch that wraps its whole process block withStop-Function -Continue(public/Expand-DbaDbLogFile.ps1:689). 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. No lab trigger was found for that outer catch: every failure inside it is caught by the per-database loop, so the site is latent as far as the lab can tell, and the fix mirrors the pattern of #10637.What changed
The
-Continueis dropped; the catch is the last statement of the process block. The message of that catch also read a variable that does not exist,$_InvocationInfo, so the line number was always empty; it is$_.InvocationInfonow.Tests
No new test: no trigger reaches the outer catch. The existing test file passes on both editions through the testing-dbatools harness.
created by Claude and reviewed by Andreas Jordan
🤖 Generated with Claude Code