Restore-DbaDatabase - Say that nothing was restored when the selection is empty - #10692
Merged
Conversation
…n is empty Without -EnableException, Select-DbaBackupInformation only warns when no restorable backup is left - no full backup anchors the chain, or nothing is newer than the continue point - and the command handed the empty selection on to the restore, which returned nothing and looked like success. A script that restores and then uses the database went on against a database that was never restored. The command now stops with a warning that names the database and says that nothing was restored, right after the selection. The warning before it still names what was missing. With -EnableException the selection already throws since #10631, so that path is unchanged, and the contract stays a warning: callers who point the command at possibly empty paths on purpose are not turned into failures. Fixes #10657 (do Restore-DbaDatabase) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
potatoqualitee
approved these changes
Sep 12, 2026
potatoqualitee
left a comment
Member
There was a problem hiding this comment.
The empty-selection guard reports that no restore occurred without changing the existing EnableException behavior or normal restore paths. The regression test covers the concrete missing-full-backup case; unrelated MinIO failures do not affect this patch.
Collaborator
Author
|
The red created by Claude and reviewed by Andreas Jordan |
Member
|
fixed! thank you 🙏🏼 |
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.
Fixes #10657
Problem
When the backup information pipeline selects nothing restorable - diff and log backups without the full that anchors the chain, or nothing newer than the continue point -
Select-DbaBackupInformationstops. With-EnableExceptionthat throws since #10631. Without it, the stop is a warning, andRestore-DbaDatabasehanded the empty selection on to the restore, which returned nothing. The only trace was the low-level "Fullname property not found" warning; the empty result looked like a successful restore, and a script that restores and then uses the database went on against a database that was never restored. The years-flakyGet-DbaDbRestoreHistorytests (#10620) were exactly this.What changed
Option 2 from the issue: the command stops right after the selection when it is empty, with a warning that says so and names the database and instance:
The warning from the selection still comes first and names what was missing. The check sits after
-StopAfterSelectBackupInformation, so that switch keeps returning the (empty) selection as before.What deliberately did not change
The contract. Without
-EnableExceptionthis is still a warning and an empty result, so callers who point the command at possibly empty paths on purpose are not turned into failures (option 3 in the issue). With-EnableExceptionnothing changes: the selection already throws before this check is reached. The empty-path case ("No backups passed through") already stopped with its own message since #10631 and is untouched.Tests
The #10621 context in
Restore-DbaDatabase.Tests.ps1now asserts, without-EnableException, that both warnings are present and that the new one names the database, and gets a fourth test for the empty path without-EnableException(warns "No backups passed through", returns nothing). Through the testing-dbatools harness: green on both editions with the fix; red without the command change on the "Nothing to restore" assertion.created by Claude and reviewed by Andreas Jordan
🤖 Generated with Claude Code