Skip to content

Progress bars - Complete the bars that 22 commands left behind - #10660

Draft
andreasjordan wants to merge 1 commit into
developmentfrom
fix-progress-bar-cleanup
Draft

Progress bars - Complete the bars that 22 commands left behind#10660
andreasjordan wants to merge 1 commit into
developmentfrom
fix-progress-bar-cleanup

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Draft on purpose - this is the tactical half of the progress-bar topic, parked since 2026-08-10 while the structural RFC (#10548) waits for maintainer opinions. Opening it as a draft so it can be looked at without implying it should merge before that discussion.

What this fixes

An AST scan over the module found 22 commands that start a Write-Progress bar and never complete it at all - on any path, success included. Their stale bars stay on screen until some later command happens to reuse the same progress Id, or the pipeline ends.

This PR adds the missing Write-Progress -Completed calls: 25 completion calls across 22 commands, 30 insertions, no logic changes.

What this deliberately does not fix

The second class found by the same scan: commands that complete their bar on the success path but leak it when they throw under -EnableException (confirmed example: Add-DbaAgDatabase, whose completion sits after the foreach and whose 28 Stop-Function calls all throw past it). That class needs a structural answer - completing bars from inside Stop-Function, as proposed in #10548 - rather than 28 hand-placed completions, and is left out here on purpose.

Scan notes for reviewers: a bar is identified by -Id (default 0), not by its Activity text, so Activity mismatches are not leaks; and Invoke-Parallel.ps1 is a permanent false positive for grep-based scans (the splat carries the Id, completed later).

Testing

All 22 affected test files were run individually against the lab at the time the branch was built (2026-08-10): 171 passed, 0 failed, 7 pre-existing skips. Write-Progress writes zero bytes to stdout/stderr when redirected, so these calls cannot affect captured test output; CI additionally suppresses progress rendering via $ProgressPreference in its runner scripts.

The branch is based on development as of 2026-08-10; only one of the 22 files (Set-DbaNetworkCertificate.ps1) has changed on development since, and the merge is conflict-free.

References #10548.

created by Claude and reviewed by Andreas Jordan

馃 Generated with Claude Code

These commands started a progress bar with Write-Progress or Write-ProgressHelper
and never completed it, so the bar stayed on screen after the command returned.
Each one now completes its bar, using the pattern the rest of the module already
uses. Commands that run a sequential and a parallel branch complete both, and the
bars started with an explicit -Id are completed with that same Id.

Remove-DbaNetworkCertificate also drops four -Target arguments passed to
Write-ProgressHelper, which has no such parameter. The helper is a simple
function, so the argument was silently landing in $args and doing nothing.

(do Disable-DbaDbEncryption, Export-DbaUser, Find-DbaInstance, Import-DbaCsv, Import-DbaParquet, Install-DbaSqlWatch, Invoke-DbaDbDataGenerator, Invoke-DbaDbDataMasking, Invoke-DbaDbMirroring, New-DbaComputerCertificate, New-DbaComputerCertificateSigningRequest, New-DbatoolsSupportPackage, Read-DbaBackupHeader, Remove-DbaNetworkCertificate, Reset-DbaAdmin, Save-DbaDiagnosticQueryScript, Set-DbaNetworkCertificate, Start-DbaDbEncryption, Start-DbaMigration, Stop-DbaDbEncryption, Sync-DbaAvailabilityGroup, Sync-DbaLoginPermission)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant