dataplat / dbatools

🚀 SQL Server automation and instance migrations have never been safer, faster or freer
https://dbatools.io
MIT License
2.43k stars 794 forks source link

[Bug] Multiple commands are broken after Get-DbaBuildReference fix #6445

Closed nvarscar closed 4 years ago

nvarscar commented 4 years ago

Environmental information

#### PowerShell version:

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.18362.628                                                                           
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.18362.628                                                                          
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 

#### dbatools Module version:

Report

After merging https://github.com/sqlcollaborative/dbatools/commit/6752767e1019a3150c2b7f35f66e22f966c2fa05 several commands are reporting issues as seen in https://ci.appveyor.com/project/sqlcollaborative/dbatools/builds/31696952

Host used

If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe

Errors Received

PSMessageDetails      :
Exception             : System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on
                        parameter 'MajorVersion'. The argument is null or empty. Provide an argument that is not null
                        or empty, and then try the command again. --->
                        System.Management.Automation.ValidationMetadataException: The argument is null or empty.
                        Provide an argument that is not null or empty, and then try the command again.
                           at System.Management.Automation.ValidateNotNullOrEmptyAttribute.Validate(Object arguments,
                        EngineIntrinsics engineIntrinsics)
                           at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal
                        parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
                        funcContext, Exception exception)
                           at Get-SqlInstanceUpdate<Process>(Closure , FunctionContext )
                           at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object
                        dollarUnderbar, Object inputToProcess)
                           at System.Management.Automation.PSScriptCmdlet.DoProcessRecord()
                           at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          :
CategoryInfo          : InvalidData: (:) [Get-DbaBuildReference], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationError,Get-DbaBuildReference
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Get-SqlInstanceUpdate<Process>,
                        C:\git\dbatools-nvarscar\internal\functions\Get-SqlInstanceUpdate.ps1: line 122
                        at Update-DbaInstance<Process>, C:\git\dbatools-nvarscar\functions\Update-DbaInstance.ps1:
                        line 361
                        at <ScriptBlock>, C:\git\dbatools-nvarscar\tests\Update-DbaInstance.Tests.ps1: line 638
                        at PesterThrow, C:\Program
                        Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\Assertions\PesterThrow.ps1: line 14
                        at Invoke-LegacyAssertion, C:\Program
                        Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\Assertions\Should.ps1: line 185
                        at Should<End>, C:\Program
                        Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\Assertions\Should.ps1: line 137
                        at <ScriptBlock>, C:\git\dbatools-nvarscar\tests\Update-DbaInstance.Tests.ps1: line 638
                        at Invoke-Test, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\It.ps1: line
                        283
                        at ItImpl, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\It.ps1: line 231
                        at It, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\It.ps1: line 121
                        at <ScriptBlock>, C:\git\dbatools-nvarscar\tests\Update-DbaInstance.Tests.ps1: line 637
                        at DescribeImpl, C:\Program
                        Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\Describe.ps1: line 171
                        at Context, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\Context.ps1:
                        line 72
                        at <ScriptBlock>, C:\git\dbatools-nvarscar\tests\Update-DbaInstance.Tests.ps1: line 597
                        at DescribeImpl, C:\Program
                        Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\Describe.ps1: line 171
                        at Describe, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.3\Functions\Describe.ps1:
                        line 85
                        at <ScriptBlock>, C:\git\dbatools-nvarscar\tests\Update-DbaInstance.Tests.ps1: line 7
                        at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.3\Pester.psm1: line 847
                        at Invoke-Pester<End>, C:\Program Files\WindowsPowerShell\Modules\Pester\4.4.3\Pester.psm1:
                        line 862
                        at <ScriptBlock>, C:\git\dbatools-nvarscar\tests\manual.pester.ps1: line 230
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

Steps to Reproduce

Run failed tests for Update-DbaInstance or Test-DbaBuild

Expected Behavior

-Update switch should not intervene with the command behavior

Actual Behavior

It does

wsmelton commented 4 years ago

The change referenced was not a real change other than changing the order of the message being written and adding output message when nothing is being updated.

How would that effect detecting a property in the file itself?

nvarscar commented 4 years ago

Right now the function outputs nothing (and throws error) when used without -Update:

WARNING: [11:12:00][Get-DbaBuildReference] Build, Update are mutually exclusive. Please choose one or the other.        Quitting.
nvarscar commented 4 years ago

Sorry, I thought the error message is included in the error output, but seems like it wasn't.

wsmelton commented 4 years ago

Yeah, this PR has not been merged yet to fix it. #6441