chocolatey / cChoco

Community resource to manage Chocolatey
Apache License 2.0
154 stars 99 forks source link

cChocoPackageInstall: Get-TargetResource fails due to non-null Source parameter validation #149

Closed ralish closed 3 years ago

ralish commented 3 years ago

Describe the bug The Get-TargetResource function for the cChocoPackageInstall resource enforces a non-null/empty Source parameter, but the cChocoPackageInstallerSet composite resource unconditionally sets the Source parameter. If the Source parameter isn't provided in configurations which use this composite resource, calls to Get-DscConfiguration after applying it will fail as they'll implicitly call Get-TargetResource with a null/empty Source parameter.

To Reproduce

  1. Apply a configuration with a cChocoPackageInstallerSet resource and do not specify the Source parameter.
  2. Invoke Get-DscConfiguration and observe the exception:
Get-DscConfiguration : PowerShell DSC resource cChocoPackageInstall  failed to execute Get-TargetResource
functionality with error message: Cannot validate argument on parameter 'Source'. The argument is null or empty.
Provide an argument that is not null or empty, and then try the command again.
At line:1 char:1
+ Get-DscConfiguration
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (MSFT_DSCLocalConfigurationManager:root/Microsoft/...gurationManager)
   [Get-DscConfiguration], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure,Get-DscConfiguration

Expected behavior Get-DscConfiguration should successfully return after applying the configuration.

Screenshots N/A

Software (please complete the following information):

Additional context N/A