microsoft / winget-dsc

MIT License
23 stars 14 forks source link

[PythonPip3Dsc/Pip3Package]: Installed status is determined by the last package in the array #46

Closed mdanish-kh closed 4 months ago

mdanish-kh commented 4 months ago

Brief description of your issue

When using the Pip3Package resource, the InstalledStatus is essentially determined by whether the final package in the array is installed or not, instead of being determined by checking every package in the array.

Steps to reproduce

requests is a valid pip3 package installed on my machine. If I try doing:

~ $config = @{ Packages = ("requests", "packageDoesNotExist") }
~ Invoke-DscResource -Name Pip3Package -Method Get -Property $pip3PackageConfig

SID               :
Ensure            : Present
Packages          : {requests, packageDoesNotExist}
Arguments         :
InstalledStatus   : False
InstalledPackages : {aiohttp, aiohttp-retry, aiosignal, asgiref…}

Which is the correct output since a package named packageDoesNotExist is not installed on my machine. But now if I swap the order of the packages:

~ $config = @{ Packages = ("requests", "packageDoesNotExist") }
~ Invoke-DscResource -Name Pip3Package -Method Get -Property $pip3PackageConfig

SID               :
Ensure            : Present
Packages          : {packageDoesNotExist, requests}
Arguments         :
InstalledStatus   : True
InstalledPackages : {aiohttp, aiohttp-retry, aiosignal, asgiref…}

Which is incorrect, since I expect InstalledStatus to still be false because of the non-existent package

Expected behavior

InstalledStatus to be False in both examples

Actual behavior

InstalledStatus is true because it essentially is returning the existence of the final package instead of the whole list.

Environment

Latest code of Pip3 module in the repository