Fix checks for local user config file paths#26269
Merged
TravisEz13 merged 3 commits intoPowerShell:masterfrom Oct 22, 2025
Merged
Fix checks for local user config file paths#26269TravisEz13 merged 3 commits intoPowerShell:masterfrom
TravisEz13 merged 3 commits intoPowerShell:masterfrom
Conversation
- Use the `DoNotVerify` option with `Environment.GetFolderPath`, ensuring the configured location will be returned regardless of if it has been created already - If we get an empty string, null or whitespace from `GetFolderPath`, consider that as disabled and skip loading or processing further for that location.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes user config handling by ensuring PowerShell uses DoNotVerify option when retrieving special folder paths, preventing failures when directories don't exist yet. The main changes ensure that if a special folder path is empty or null, config loading is skipped for that location rather than failing.
Key Changes:
- Added
DoNotVerifyoption toEnvironment.GetFolderPathcalls to return configured paths regardless of directory existence - Added null/empty checks to skip processing when special folder paths are unavailable
- Introduced helper methods
SafeDeriveFromSpecialFolderandTryDeriveFromCacheto safely derive paths from special folders
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| CorePsPlatform.cs | Added helper methods for safe path derivation and updated cache/config directory initialization to use DoNotVerify |
| PSConfiguration.cs | Added null check before using per-user config file path |
| Telemetry.cs | Updated to use cached UUID path and skip telemetry if path unavailable; moved environment variable parsing to private method |
| AnalysisCache.cs | Updated to use TryDeriveFromCache and skip serialization if cache location unavailable |
| UpdatesNotification.cs | Updated to use TryDeriveFromCache and disable notifications if cache unavailable |
| ConsoleHost.cs | Added null check before using profile directory |
| CommandDiscovery.cs | Updated user profile path retrieval to use DoNotVerify option |
| MshHostUserInterface.cs | Added null/empty check for base directory in transcript path generation |
| HostUtilities.cs | Fixed brace placement in conditional logic |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
TravisEz13
approved these changes
Oct 21, 2025
Contributor
|
📣 Hey @@SeeminglyScience, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
SIRMARGIN
pushed a commit
to SIRMARGIN/PowerShell
that referenced
this pull request
Dec 12, 2025
kilasuit
pushed a commit
to kilasuit/PowerShell
that referenced
this pull request
Jan 2, 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.
PR Summary
With these changes,
SYSTEM's default config path isC:\Windows\system32\config\systemprofile\Documents\PowerShell\powershell.config.jsonregardless of if the directoryDocumentsexists.If the location for
Documentsis configured in the OS to be an empty string (if that's even possible), user based config loading will be skipped entirely.PR Context
DoNotVerifyoption withEnvironment.GetFolderPath, ensuring the configured location will be returned regardless of if it has been created alreadyGetFolderPath, consider that as disabled and skip loading or processing further for that location.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header