Restore-DbaDatabase - Honor EnableException in the backup information pipeline - #10631
Open
andreasjordan wants to merge 1 commit into
Open
Restore-DbaDatabase - Honor EnableException in the backup information pipeline#10631andreasjordan wants to merge 1 commit into
andreasjordan wants to merge 1 commit into
Conversation
… pipeline The splats for Get-DbaBackupInformation and Select-DbaBackupInformation never passed EnableException on, so with -EnableException a missing full backup (or a failed scan) degraded to a warning inside the callee, control returned, and the restore continued as a successful-looking no-op over an empty backup history. The empty-history bail-out was a plain warning for the same reason. This is how a test fixture could restore diff+log without their full for years and only fail on a minute boundary (#10620). EnableException now flows into both splats and into the per-file Get-DbaBackupInformation call of the SQL Server 2000 path, and the "No backups passed through" bail-out is a Stop-Function. Without -EnableException nothing changes: Stop-Function writes the identical warning and returns. The Test-DbaBackupInformation call already ran with EnableException inside try/catch and stays as it is, and Format-DbaBackupInformation has no failure path to propagate. Verified in the lab on SQL03\SQL2019: 84 tests, 76 passed, 0 failed, 7 skipped, including three new regression tests - diff+log without the full throws with EnableException, still warns and returns nothing without it, and an empty directory throws instead of warning. Fixes #10621 (do Restore-DbaDatabase) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 29, 2026
potatoqualitee
approved these changes
Aug 30, 2026
potatoqualitee
left a comment
Member
There was a problem hiding this comment.
Reviewed the complete current head, all backup-information propagation paths, empty-history behavior, regression coverage, and exact-head SQL CI evidence. No material correctness or compatibility issues found.
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.
Summary
Fixes #10621. When
Restore-DbaDatabaseis given backups without a full to anchor the chain,Select-DbaBackupInformationcorrectly callsStop-Function- but the splatRestore-DbaDatabasebuilds for it never passedEnableExceptionon, so under-EnableExceptionthe stop degraded to a warning, control returned, and the restore proceeded over an empty$FilteredBackupHistoryto a successful-looking no-op. A caller relying on the promised exception (a test fixture, or any script that restores and then uses the database) continued as if the restore had happened - exactly howGet-DbaDbRestoreHistory.Tests.ps1was flaky for years (#10620).What changed
EnableException = $EnableExceptionadded to theSelect-DbaBackupInformationsplat and theGet-DbaBackupInformationsplat, and to the per-fileGet-DbaBackupInformationcall on the SQL Server 2000 path (now a splat, since it grew to three parameters).Stop-Functioninstead of a plainWrite-Message -Level Warning, so it too honors-EnableException.What deliberately did not change
-EnableExceptionnothing changes:Stop-Functionwrites the identical warning and returns, so the default warn-and-return behavior is untouched. The open behavior question from Restore-DbaDatabase -EnableException restores nothing with only a warning when no full backup anchors the chain #10621 - whether an empty selection should also stop the non-exception path - is left for a maintainer decision.Test-DbaBackupInformationcall already passedEnableException = $trueinside try/catch and stays as it is.Format-DbaBackupInformationcontains noStop-Functionat all, so there is nothing to propagate.Get-DbaAgBackupHistoryhas the same gap on itsSelect-DbaBackupInformationcall and gets its own pull request, one command per PR.Tests
Three regression tests in a new context, each backup written to its own file so the minute-resolution default name cannot hide the missing full by merging it into the diff's file:
*Fullname property not found*with-EnableException(the exact repro from the issue),*No backups passed through*with-EnableException.Full file verified via the lab harness on SQL03\SQL2019: 84 tests, 76 passed, 0 failed, 7 skipped (the documented StopAt and Azure skips), lab left clean.
created by Claude and reviewed by Andreas Jordan
🤖 Generated with Claude Code