PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
496 stars 94 forks source link

Register/Set-PSRepository should error if API version is unknown #1418

Open ThomasNieto opened 1 year ago

ThomasNieto commented 1 year ago

Prerequisites

Steps to reproduce

If you're registering a repository and it cannot figure out the API version via auto discovery (test v3 or v2, etc) and the user did not specify the API version then the repository should not be registered. From what I can tell the resource lifecycle cmdlets will not work with an unknown repository type so there is no need to register a non-working repository.

Expected behavior

If API version is not auto discovered or user provided do not register or update the repository URL. (Fail fast)

Actual behavior

Repository is registered creating errors in resource lifecycle cmdlets.

Error details

No response

Environment data

7.4-preview5
rc1

Visuals

No response

SydneyhSmith commented 1 year ago

thanks, we should default to v3 and then if we guessed the api version there should be a warning emitted at registration time, we should not set to unknown in the feature as this is known to break

ThomasNieto commented 1 year ago

I don't understand what you mean by guessing.

Surely there is a way test the endpoint if it accept a v3 or v2 request. During my impromptu testing if the end point returned json then it was v3 and if it returned xml it was v2. Also since it's testing a registration time it would not be end user impacting to wait for multiple test calls to return to determine api version.