[release/v7.6.2] Fix checks for local user config file paths#27432
Merged
daxian-dbw merged 1 commit intoMay 13, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
SafeDeriveFromSpecialFolderandTryDeriveFromCachehelpers inPlatform/CorePsPlatform.cs, and passDoNotVerifytoEnvironment.GetFolderPathso 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. |
SeeminglyScience
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Customer Impact
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.
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.
Targeted fix to config path resolution logic. Only affects edge cases (SYSTEM account path and empty GetFolderPath results). No behavioral change for standard users.