-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
Currently if you try to register/set a repository to have a lower priority (number higher than 50) than the default PSGallery priority you'll get an error. This is because the parameter only accepts ranges from 0-50
. In the original RFC it was discussed that PSGallery would have a default value of 50 and be neutral priority so you could register repositories higher or lower priority than PSGallery without having to change PSGallery priority.
The second issue is intuitiveness, -Priority
parameter currently has a type of [Int32]
which accepts both positive and negative numbers. This is not intuitive to the user as they would need to read the help to understand how the priority system works. However, if you change the type to [byte]
that only allows values from 0-255
a much more reasonable range. Then PSGallery can be a neutral priority of 100
close enough to halfway of accepted values.
If changing the type is unacceptable my request would be to have the range be 0-100
with newly registered repositories and PSGallery at a neutral priority of 50
.
Expected behavior
Register-PSResourceRepository -Name Test -Uri c:\temp -Priority 100
Actual behavior
PS C:\> Register-PSResourceRepository -Name test -Uri c:\temp -Priority 100
Register-PSResourceRepository: Cannot validate argument on parameter 'Priority'. The 100 argument is greater than the maximum allowed range of 50. Supply an argument that is less than or equal to 50 and then try the command again.
Error details
Exception :
Type : System.Management.Automation.ParameterBindingValidationException
Message : Cannot validate argument on parameter 'Priority'. The 100 argument is greater than the maximum
allowed range of 50. Supply an argument that is less than or equal to 50 and then try the command again.
ParameterName : Priority
ParameterType : int
TypeSpecified : int
ErrorId : ParameterArgumentValidationError
Line : 1
Offset : 65
CommandInvocation :
MyCommand : Register-PSResourceRepository
BoundParameters :
Comparer : System.OrdinalIgnoreCaseComparer
Count : 2
Keys :
Length : 4
Length : 3
Values :
Length : 4
Length : 7
SyncRoot :
Comparer : System.OrdinalIgnoreCaseComparer
Count : 2
Keys :
Length : 4
Length : 3
Values :
Length : 4
Length : 7
SyncRoot :
Comparer : System.OrdinalIgnoreCaseComparer
Count : 2
Keys :
Length : 4
Length : 3
Values :
Length : 4
Length : 7
SyncRoot :
Comparer : System.OrdinalIgnoreCaseComparer
Count : 2
Keys :
Length : 4
Length : 3
Values :
Length : 4
Length : 7
SyncRoot :
Comparer : System.OrdinalIgnoreCaseComparer
Count : 2
Keys :
Length : 4
Length : 3
Values :
Length : 4
Length : 7
SyncRoot :
Comparer : System.OrdinalIgnoreCaseComparer
Count : 2
Keys :
Length : 4
Length : 3
Values :
Length : 4
Length : 7
SyncRoot :
Comparer : System.OrdinalIgnoreCaseComparer
Count : 2
Keys : …
Values : …
SyncRoot : …
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 45
Line : Register-PSResourceRepository -Name test -Uri c:\temp -Priority 100
PositionMessage : At line:1 char:1
+ Register-PSResourceRepository -Name test -Uri c:\temp -Priority 100
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : Register-PSResourceRepository
PipelineLength : 1
PipelinePosition : 1
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Cannot validate argument on parameter 'Priority'. The 100 argument is greater than the maximum
allowed range of 50. Supply an argument that is less than or equal to 50 and then try the command again.
HResult : -2146233087
CategoryInfo : InvalidData: (:) [Register-PSResourceRepository], ParentContainsErrorRecordException
FullyQualifiedErrorId :
ParameterArgumentValidationError,Microsoft.PowerShell.PowerShellGet.Cmdlets.RegisterPSResourceRepository
InvocationInfo :
MyCommand : Register-PSResourceRepository
ScriptLineNumber : 1
OffsetInLine : 65
HistoryId : 45
Line : Register-PSResourceRepository -Name test -Uri c:\temp -Priority 100
PositionMessage : At line:1 char:65
+ Register-PSResourceRepository -Name test -Uri c:\temp -Priority 100
+ ~~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
TargetSite :
Name : BindParameter
DeclaringType : System.Management.Automation.ParameterBinderBase, System.Management.Automation,
Version=7.2.5.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : System.Management.Automation.ValidationMetadataException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The 100 argument is greater than the maximum allowed range of 50. Supply an argument that is
less than or equal to 50 and then try the command again.
HResult : -2146233087
CategoryInfo : MetadataError: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : ValidateRangeTooBig
TargetSite :
Name : ValidateRange
DeclaringType : ValidateRange
MemberType : Method
Module : System.Management.Automation.dll
Message : The 100 argument is greater than the maximum allowed range of 50. Supply an argument that is
less than or equal to 50 and then try the command again.
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.ValidateRangeAttribute.ValidateRange(Object element)
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter,
CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter,
CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument,
MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets,
CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
at System.Management.Automation.CmdletParameterBinderController.BindNamedParameter(UInt32 parameterSets,
CommandParameterInternal argument, MergedCompiledCommandParameter parameter)
at System.Management.Automation.ParameterBinderController.BindNamedParameters(UInt32 parameterSets, Collection`1
arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1
arguments)
at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location ---
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]
commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
CategoryInfo : InvalidData: (:) [Register-PSResourceRepository], ParameterBindingValidationException
FullyQualifiedErrorId :
ParameterArgumentValidationError,Microsoft.PowerShell.PowerShellGet.Cmdlets.RegisterPSResourceRepository
InvocationInfo :
MyCommand : Register-PSResourceRepository
ScriptLineNumber : 1
OffsetInLine : 65
HistoryId : 45
Line : Register-PSResourceRepository -Name test -Uri c:\temp -Priority 100
PositionMessage : At line:1 char:65
+ Register-PSResourceRepository -Name test -Uri c:\temp -Priority 100
+ ~~~
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
Environment data
Name Version
---- -------
PowerShellGet 3.0.14
Name Value
---- -----
PSVersion 7.2.5
PSEdition Core
GitCommitId 7.2.5
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response