Fix requiring 'tags' in server response#1627
Merged
alerickson merged 1 commit intoPowerShell:masterfrom Apr 12, 2024
Merged
Conversation
FindNameHelper and FindVersionHelper now properly allows a server response that has no 'tags' element in the case of the user not using the -Tag parameter with Find-PSResource.
anamnavi
approved these changes
Apr 10, 2024
Member
anamnavi
left a comment
There was a problem hiding this comment.
LGTM, thanks for putting in this fix @evelyn-bi ! :) I need to check why the tests haven't run but once they do we can merge it in.
Member
|
/azp run PowerShell.PSResourceGet |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
-Tagparameter. Using Find-PSResource with-Tagstill 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
-Tagparameter 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-PSResourceandInstall-PSResourcebecause they both use the code that requires the 'tags' element and error out.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.