Skip to content

[release/v7.4.21] Tolerate IO/JSON errors reading the per-user powershell.config.json - #28048

Merged
Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:release/v7.4.21from
adityapatwardhan:backport/release/v7.4.21/27373-84a930151
Sep 22, 2026
Merged

Aditya Patwardhan (adityapatwardhan) merged 1 commit into
PowerShell:release/v7.4.21from
adityapatwardhan:backport/release/v7.4.21/27373-84a930151

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

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

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

Customer Impact

  • Customer reported
  • Found internally

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.

  • Yes
  • No

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.

  • High
  • Medium
  • Low

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.

Copilot AI lite review requested due to automatic review settings September 21, 2026 21:21
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Sep 21, 2026
@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.

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 Medium severity

Open (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))
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) merged commit a88a8cf into PowerShell:release/v7.4.21 Sep 22, 2026
37 checks passed
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.

4 participants