Skip to content

Get-DbaBackupInformation - Fix inconsistencies with Get-DbaDbBackupHistory#10308

Draft
andreasjordan wants to merge 4 commits intodevelopmentfrom
claude/issue-8205-20260403-1527
Draft

Get-DbaBackupInformation - Fix inconsistencies with Get-DbaDbBackupHistory#10308
andreasjordan wants to merge 4 commits intodevelopmentfrom
claude/issue-8205-20260403-1527

Conversation

@andreasjordan
Copy link
Copy Markdown
Collaborator

@andreasjordan andreasjordan commented Apr 3, 2026

Fixes inconsistencies between Get-DbaBackupInformation and Get-DbaDbBackupHistory as reported in #8205.

Changes:

  • Normalize Type values to match Get-DbaDbBackupHistory ("Database" → "Full", etc.)
  • Rename FileList property Type to FileType
  • Fix LastRecoveryForkGuid (was always "00000000-0000-...")
  • Fix InstanceName (extract from ServerName when ServiceName is empty)

Closes #8205

Generated with Claude Code

IMPORTANT: This is a breaking change so maybe merge later together with other breaking changes and release a new version 2.8.0

…story

- Normalize Type values: 'Database' -> 'Full', 'Database Differential' -> 'Differential', 'Transaction Log' -> 'Log'
- Rename FileList property 'Type' to 'FileType' to match Get-DbaDbBackupHistory
- Add LastRecoveryForkGuid assignment (was always 00000000-0000-...)
- Fix InstanceName: extract from ServerName when ServiceName is empty

Fixes #8205

(do Get-DbaBackupInformation)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@andreasjordan
Copy link
Copy Markdown
Collaborator Author

@claude now the tests for Restore-DbaDatabase fail.

@claude
Copy link
Copy Markdown

claude bot commented Apr 4, 2026

Claude finished @andreasjordan's task in 2m 56s —— View job


Fix: Restore-DbaDatabase test failure

  • Analyze PR changes
  • Find why Restore-DbaDatabase tests fail
  • Fix the issue
  • Commit and push fix

Root cause: The new line assigning LastRecoveryForkGuid threw an exception when LastRecoveryForkGUID is $null in the backup header (e.g. Azure blob storage backups):

Exception setting "LastRecoveryForkGuid": "Cannot convert null to type "System.Guid"."

Fix: Added a null-check before assigning the value, so when LastRecoveryForkGUID is null the property is left at its default (Guid.Empty), which is the same behaviour as before the PR:

if ($null -ne $group.Group[0].LastRecoveryForkGUID) {
    $historyObject.LastRecoveryForkGuid = $group.Group[0].LastRecoveryForkGUID
}

Commit: 3917716
| Branch

Prevents "Cannot convert null to type System.Guid" error when
LastRecoveryForkGUID is null in backup headers (e.g. Azure blob storage).

(do Get-DbaBackupInformation)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@andreasjordan andreasjordan marked this pull request as draft April 4, 2026 09:34
@andreasjordan
Copy link
Copy Markdown
Collaborator Author

@claude the tests for Restore-DbaDatabase now pass, but these tests for Get-DbaBackupInformation fail:

Failed tests summary:
Path           : Get-DbaBackupInformation/Get history for all database/Should return 2 full backups
Name           : It Should return 2 full backups
Result         : Failed
Message        : ErrorRecord: Expected exactly 2, but got 0.
StackTrace     : 
RawErrorRecord : Expected exactly 2, but got 0.
Path           : Get-DbaBackupInformation/Get history for all database/Should return 2 log backups
Name           : It Should return 2 log backups
Result         : Failed
Message        : ErrorRecord: Expected exactly 2, but got 0.
StackTrace     : 
RawErrorRecord : Expected exactly 2, but got 0.
Path           : Get-DbaBackupInformation/Get history for one database/Should Be 1 full backup
Name           : It Should Be 1 full backup
Result         : Failed
Message        : ErrorRecord: Expected exactly 1, but got 0.
StackTrace     : 
RawErrorRecord : Expected exactly 1, but got 0.
Path           : Get-DbaBackupInformation/Get history for one database/Should be 1 log backups
Name           : It Should be 1 log backups
Result         : Failed
Message        : ErrorRecord: Expected exactly 1, but got 0.
StackTrace     : 
RawErrorRecord : Expected exactly 1, but got 0.
Path           : Get-DbaBackupInformation/Test Maintenance solution options/Should Be 1 full backup
Name           : It Should Be 1 full backup
Result         : Failed
Message        : ErrorRecord: Expected exactly 1, but got 0.
StackTrace     : 
RawErrorRecord : Expected exactly 1, but got 0.
Path           : Get-DbaBackupInformation/Test Maintenance solution options/Should Be 1 full backup when ignoring log backups
Name           : It Should Be 1 full backup when ignoring log backups
Result         : Failed
Message        : ErrorRecord: Expected exactly 1, but got 0.
StackTrace     : 
RawErrorRecord : Expected exactly 1, but got 0.
Path           : Get-DbaBackupInformation/Test Maintenance solution options/Should be 1 log backups
Name           : It Should be 1 log backups
Result         : Failed
Message        : ErrorRecord: Expected exactly 1, but got 0.
StackTrace     : 
RawErrorRecord : Expected exactly 1, but got 0.

@claude
Copy link
Copy Markdown

claude bot commented Apr 4, 2026

Claude finished @andreasjordan's task in 1m 21s —— View job


Fix: Get-DbaBackupInformation test failures

  • Analyze failing tests
  • Read test file and implementation
  • Identify root cause
  • Fix the issue
  • Commit and push

Root cause: The tests were filtering by the old Type values ("Database" and "Transaction Log"), but the PR changed the normalized values to "Full" and "Log" to match Get-DbaDbBackupHistory.

Fix: Updated 5 test assertions in tests/Get-DbaBackupInformation.Tests.ps1:

  • "Database""Full" (3 occurrences)
  • "Transaction Log""Log" (2 occurrences)

Commit: 4357500
| Branch

github-actions bot and others added 2 commits April 4, 2026 10:54
Update test assertions to use the new normalized Type values
('Full', 'Log') instead of the old values ('Database', 'Transaction Log')
to match the changes made in the implementation.

(do Get-DbaBackupInformation)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.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.

Get-DbaBackupInformation and Get-DbaDbBackupHistory return inconsistent values

1 participant