mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix retrieving dynamic parameters from provider even if globbed path returns no results (#15525)
This commit is contained in:
@@ -4681,7 +4681,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
if (providerPath != null)
|
||||
if (providerInstance != null)
|
||||
{
|
||||
// Get the dynamic parameters for the first resolved path
|
||||
return CopyItemDynamicParameters(providerInstance, providerPath, destination, recurse, newContext);
|
||||
@@ -4733,10 +4733,6 @@ namespace System.Management.Automation
|
||||
providerInstance != null,
|
||||
"Caller should validate providerInstance before calling this method");
|
||||
|
||||
Dbg.Diagnostics.Assert(
|
||||
path != null,
|
||||
"Caller should validate path before calling this method");
|
||||
|
||||
Dbg.Diagnostics.Assert(
|
||||
context != null,
|
||||
"Caller should validate context before calling this method");
|
||||
|
||||
@@ -256,6 +256,14 @@ Describe "Parameter Binding Tests" -Tags "CI" {
|
||||
DynamicParamTest -PipelineVariable bar | ForEach-Object { $bar } | Should -Be "hi"
|
||||
}
|
||||
|
||||
It 'Dynamic parameter is found even if globbed path does not exist' {
|
||||
$guid = New-Guid
|
||||
|
||||
# This test verifies that the ErrorRecord is coming from parameter validation on a dynamic parameter
|
||||
# instead of an error indicating that the dynamic parameter is not found
|
||||
{ Copy-Item "~\$guid*" -Destination ~ -ToSession $null } | Should -Throw -ErrorId 'ParameterArgumentValidationError'
|
||||
}
|
||||
|
||||
Context "PipelineVariable Behaviour" {
|
||||
|
||||
BeforeAll {
|
||||
|
||||
Reference in New Issue
Block a user