Visitar URL original
Slai Agent Runtime: add experimental provider dynamic parameter errors by huong8373tt-beep · Pull Request #28165 · PowerShell/PowerShell · GitHub
Skip to content

Slai Agent Runtime: add experimental provider dynamic parameter errors - #28165

Open
Slai.life (huong8373tt-beep) wants to merge 3 commits into
PowerShell:masterfrom
huong8373tt-beep:slai/experimental-dynamic-provider-errors
Open

Slai.life (huong8373tt-beep) wants to merge 3 commits into
PowerShell:masterfrom
huong8373tt-beep:slai/experimental-dynamic-provider-errors

Conversation

@huong8373tt-beep

Copy link
Copy Markdown

Summary

Adds the PSProviderDynamicParameterBindingErrors experimental feature to surface provider-resolution failures while Get-ChildItem obtains file-system dynamic parameters.

With the feature enabled, a missing PS drive or provider now reports DriveNotFound or ProviderNotFound rather than the misleading NamedParameterNotFound error for -File or -Directory.

The feature is scoped to Get-ChildItem; existing behavior remains unchanged when the feature is disabled and for valid non-file-system providers such as the Registry provider.

This was discovered while Slai Agent Runtime was operating in a Windows environment. The developer authorized this contribution after the issue was reproduced and the fix was validated.

Fixes #21141.

Validation

  • Start-PSBuild -Runtime win7-x64 -Configuration Debug
  • Start-PSPester -Path test/powershell/Modules/Microsoft.PowerShell.Management/Get-ChildItem.PSProviderDynamicParameterBindingErrors.Tests.ps1 -ExperimentalFeatureName PSProviderDynamicParameterBindingErrors -ThrowOnFailure -Terse -SkipTestToolBuild
    • 4 passed, 0 failed
  • Manual built-pwsh checks confirmed:
    • enabled: missing drive + -File / -Directory reports DriveNotFound
    • enabled: missing provider + -File reports ProviderNotFound
    • enabled: HKCU:\Software -File remains NamedParameterNotFound
    • disabled: existing NamedParameterNotFound behavior remains unchanged

Copilot AI balanced review requested due to automatic review settings October 8, 2026 07:49
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Registry-provider test will fail in feature-enabled Linux builds because HKCU: is unavailable.

1 open finding
What changed in this PR

Adds an experimental feature to surface provider-resolution errors during Get-ChildItem dynamic parameter binding, addressing #21141.

Changes:

  • Propagates missing provider, drive, and item errors when enabled.
  • Limits behavior to Get-ChildItem.
  • Registers the feature and adds regression tests.
File Description
src/​System.Management.Automation/​engine/​MshCmdlet.cs Adds the internal error-reporting contract.
src/​System.Management.Automation/​engine/​CmdletParameterBinderController.cs Propagates opted-in provider-resolution errors.
src/​System.Management.Automation/​engine/​ExperimentalFeature/​ExperimentalFeature.cs Registers the experimental feature.
src/​Microsoft.PowerShell.Commands.Management/​commands/​management/​Navigation.cs Integrates error-reporting behavior into provider commands.
src/​Microsoft.PowerShell.Commands.Management/​commands/​management/​GetChildrenCommand.cs Enables the behavior for Get-ChildItem.
test/​powershell/​Modules/​Microsoft.PowerShell.Management/​Get-ChildItem.PSProviderDynamicParameterBindingErrors.Tests.ps1 Tests dynamic parameter error behavior.
test/​tools/​TestMetadata.json Associates tests with the feature.
experimental-feature-windows.json Enables the feature in Windows preview builds.
experimental-feature-linux.json Enables the feature in Linux preview builds.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

} | Should -Throw -ErrorId 'ProviderNotFound'
}

It 'continues to report file system dynamic parameters as unavailable for registry paths' {

@huong8373tt-beep Slai.life (huong8373tt-beep) Oct 8, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — this is a valid cross-platform test issue.

Updated in a8db1e3:

  • The missing-drive and missing-provider cases remain enabled whenever the experimental feature is enabled, including Linux preview builds.
  • The Registry-provider assertion now runs only when both the feature is enabled and $IsWindows is true, so feature-enabled Linux builds no longer reference HKCU:.
  • I also replaced the PSDefaultParameterValues default skip with explicit per-test -Skip conditions, so the Windows-only condition cannot be overridden by the suite default.

Re-ran the targeted Pester test with explicit feature settings locally: feature enabled: 4 passed, 0 failed, 0 skipped; feature disabled: 0 passed, 0 failed, 4 skipped.

@huong8373tt-beep

Copy link
Copy Markdown
Author

Follow-up cleanup in cb499ba.

The reporting contract is now implemented only by GetChildItemCommand, rather than by the shared CoreCommandBase, so the experimental behavior remains explicitly scoped to Get-ChildItem. I also added XML documentation for the new internal contract and members.

Revalidated after this update with a fresh Debug win7-x64 build and the feature enabled:

  • targeted Pester: 4 passed, 0 failed;
  • missing drive: DriveNotFound;
  • missing provider: ProviderNotFound;
  • Registry -File: unchanged NamedParameterNotFound.

git diff --check passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get-ChildItem not throwing consistent errors for path not found

2 participants