Skip to content

[release/v7.6.2] Fix checks for local user config file paths#27432

Merged
daxian-dbw merged 1 commit into
PowerShell:release/v7.6.2from
daxian-dbw:backport/release/v7.6.2/26269-c7ee0d294
May 13, 2026
Merged

[release/v7.6.2] Fix checks for local user config file paths#27432
daxian-dbw merged 1 commit into
PowerShell:release/v7.6.2from
daxian-dbw:backport/release/v7.6.2/26269-c7ee0d294

Conversation

@daxian-dbw
Copy link
Copy Markdown
Member

Backport of #26269 to release/v7.6.2

Triggered by @daxian-dbw on behalf of @SeeminglyScience

Original CL Label: CL-Engine

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Customer Impact

  • Customer reported
  • Found internally

Fixes incorrect config file path resolution for the SYSTEM account and handles empty/null paths from GetFolderPath, preventing potential issues loading PowerShell user config files.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Verified via the original PR. The change uses DoNotVerify option with Environment.GetFolderPath and skips loading when an empty/null/whitespace path is returned. No new tests were added as the scenario can only be tested interactively.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Targeted fix to config path resolution logic. Only affects edge cases (SYSTEM account path and empty GetFolderPath results). No behavioral change for standard users.

Copilot AI review requested due to automatic review settings May 13, 2026 20:20
@daxian-dbw daxian-dbw added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backport of #26269 to release/v7.6.2. Fixes incorrect config file path resolution for the SYSTEM account by using DoNotVerify with Environment.GetFolderPath, and gracefully skips user-config loading when the OS returns an empty/null/whitespace path.

Changes:

  • Introduce SafeDeriveFromSpecialFolder and TryDeriveFromCache helpers in Platform/CorePsPlatform.cs, and pass DoNotVerify to Environment.GetFolderPath so paths resolve regardless of directory existence.
  • Guard call sites that derive paths from CacheDirectory/ConfigDirectory/UserProfile (telemetry, analysis cache, PSConfiguration, UpdatesNotification, ConsoleHost startup, transcript path, profile path, command lookup) to handle empty results by skipping work instead of producing invalid paths.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/System.Management.Automation/CoreCLR/CorePsPlatform.cs Adds SafeDeriveFromSpecialFolder and TryDeriveFromCache helpers; uses DoNotVerify option.
src/System.Management.Automation/utils/Telemetry.cs Caches uuid path via TryDeriveFromCache; bails out early if unavailable.
src/System.Management.Automation/engine/Modules/AnalysisCache.cs Uses TryDeriveFromCache; skips serialization when location empty.
src/System.Management.Automation/engine/PSConfiguration.cs Skips per-user config file resolution and reads when directory is empty.
src/System.Management.Automation/engine/hostifaces/MshHostUserInterface.cs Returns empty transcript path when base directory empty.
src/System.Management.Automation/engine/hostifaces/HostUtilities.cs Consolidates empty basePath check for both user and all-users branches.
src/System.Management.Automation/engine/CommandDiscovery.cs Uses DoNotVerify when expanding ~ in PATH lookups.
src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs Disables update notifications when cache directory unavailable.
src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs Skips ProfileOptimization setup when cache directory empty.

@daxian-dbw daxian-dbw merged commit 783caca into PowerShell:release/v7.6.2 May 13, 2026
40 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.6.2/26269-c7ee0d294 branch May 13, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants