FindNameHelper and FindVersionHelper now properly allow a server response that has no 'tags' element. This fixes Install-PSResource not working, and fixes Find-PSResource not working in the case of the user not using the -Tag parameter. Using Find-PSResource with -Tag still properly errors out if the server does not respond with tags.
PR Summary
When the server response doesn't contain tags, the find helpers now only give an error if the user passed in -Tag {tags to find}, if the user is searching for a tag then it's necessary for the response to contain tags. But when -Tag is not used then the lack of 'tags' in the server response is now ignored and the code continues as expected. The rest of the code already handles no tags correctly.
This PR does not contain updated tests, someone responded in issue #1621 that this should be fine. Updated tests should just involve duplicating one or more existing tests around finding and installing packages but removing the 'tags' element in the server responses to verify the old code fails the test and new code passes.
PR Context
Resolves #1621
Tags are optional in the NuGet API as shown here. Before this fix, when using Find-PSResource against a server that does not return 'tags' would give an error saying the server response does not contain the 'tags' element, this occurred even in the case of the user not using the -Tag parameter to search for a tag. This behavior is seen on a local Gitea server where it does not include tags in the response for unknown reasons, but that is supposed to be allowed in the NuGet API. Also note that PowerShellGet was tested on the same server and it finds packages fine despite the server not returning the 'tags' element.
Without this fix, using PSResourceGet is unusable with Gitea for finding and installing packages with Find-PSResource and Install-PSResource because they both use the code that requires the 'tags' element and error out.
If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
FindNameHelper and FindVersionHelper now properly allow a server response that has no 'tags' element. This fixes Install-PSResource not working, and fixes Find-PSResource not working in the case of the user not using the
-Tag
parameter. Using Find-PSResource with-Tag
still properly errors out if the server does not respond with tags.PR Summary
When the server response doesn't contain tags, the find helpers now only give an error if the user passed in
-Tag {tags to find}
, if the user is searching for a tag then it's necessary for the response to contain tags. But when -Tag is not used then the lack of 'tags' in the server response is now ignored and the code continues as expected. The rest of the code already handles no tags correctly.This PR does not contain updated tests, someone responded in issue #1621 that this should be fine. Updated tests should just involve duplicating one or more existing tests around finding and installing packages but removing the 'tags' element in the server responses to verify the old code fails the test and new code passes.
PR Context
Resolves #1621
Tags are optional in the NuGet API as shown here. Before this fix, when using Find-PSResource against a server that does not return 'tags' would give an error saying the server response does not contain the 'tags' element, this occurred even in the case of the user not using the
-Tag
parameter to search for a tag. This behavior is seen on a local Gitea server where it does not include tags in the response for unknown reasons, but that is supposed to be allowed in the NuGet API. Also note that PowerShellGet was tested on the same server and it finds packages fine despite the server not returning the 'tags' element.Without this fix, using PSResourceGet is unusable with Gitea for finding and installing packages with
Find-PSResource
andInstall-PSResource
because they both use the code that requires the 'tags' element and error out.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.