[release/v7.4.21] Tolerate IO/JSON errors reading the per-user powershell.config.json - #28048
Merged
Aditya Patwardhan (adityapatwardhan) merged 1 commit intoSep 22, 2026
Conversation
…PowerShell#27373) Co-authored-by: Justin Chung <[email protected]> Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Aditya Patwardhan (adityapatwardhan)
September 21, 2026 21:22
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Moderate unresolved issues remain around access-failure warnings and test coverage.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Backports tolerant per-user powershell.config.json handling so PowerShell warns and falls back to defaults while system-wide configuration remains strict.
Changes:
- Handles per-user JSON and I/O errors.
- Adds localized warning messages.
- Adds focused fallback and warning tests.
| File | Summary | Findings |
|---|---|---|
test/xUnit/csharp/test_PSConfiguration.cs |
Tests configuration fallback and warning emission. | Add coverage for I/O failures and malformed per-key system-wide values. |
src/System.Management.Automation/resources/PSConfigurationStrings.resx |
Adds fallback warning resources. | No direct finding recorded. |
src/System.Management.Automation/engine/PSConfiguration.cs |
Implements per-user fallback and warnings. | File.Exists can mask access failures and suppress warnings (moderate, 3 votes); add system-wide type-mismatch coverage (moderate, 1 vote) and deterministic I/O-failure coverage (moderate, 1 vote). |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+415
to
+417
| catch (Exception exc) when ( | ||
| scope == ConfigScope.CurrentUser && | ||
| (exc is IOException || exc is UnauthorizedAccessException || exc is SecurityException || exc is JsonException)) |
Aditya Patwardhan (adityapatwardhan)
enabled auto-merge (squash)
September 22, 2026 19:19
Patrick Meinecke (SeeminglyScience)
approved these changes
Sep 22, 2026
Aditya Patwardhan (adityapatwardhan)
merged commit Sep 22, 2026
a88a8cf
into
PowerShell:release/v7.4.21
37 checks passed
Justin Chung (jshigetomi)
approved these changes
Sep 23, 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 #27373 to release/v7.4.21
Triggered by Aditya Patwardhan (@adityapatwardhan) on behalf of Justin Chung (@jshigetomi)
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 #27370, where transient cloud-provider, permission, or malformed JSON errors in a user's powershell.config.json could prevent PowerShell from starting. Expected behavior is a warning and fallback to defaults for per-user configuration while retaining strict system-wide handling.
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Cherry-pick completed cleanly and git diff --check passed. The original PR adds focused xUnit coverage for broken and type-mismatched current-user configuration, warning emission, and continued fail-closed behavior for system configuration. A direct focused dotnet test invocation could not run because the guessed project path was not present; CI will run the repository's configured xUnit suite.
Risk
REQUIRED: Check exactly one box.
Medium risk because this changes early-startup configuration error handling, but only for the per-user scope and with focused tests. System-wide security configuration remains fail-closed.