Skip to content

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

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

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

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

Backport of #27373 to release/v7.5.12

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

Found internally after reports of PowerShell failing at startup when a per-user powershell.config.json is temporarily unreadable or malformed. The expected behavior is to warn and fall back to defaults for the current-user file while retaining strict failure for the system-wide configuration.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

The original PR adds focused xUnit coverage for broken and type-mismatched current-user configuration, fallback defaults, warning emission, and continued system-wide strict failure. The backport cherry-picked cleanly and passes git diff --check, resource XML parsing, and conflict-marker scanning. A targeted dotnet test attempt was blocked during build by pre-existing missing DotNetEventingStrings generated resources in Microsoft.PowerShell.CoreCLR.Eventing, before the selected tests could run.

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; the system-wide security-relevant configuration remains fail-closed. The original change includes focused xUnit coverage and cherry-picked cleanly.

Copilot AI lite review requested due to automatic review settings September 23, 2026 18:12
@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 23, 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

Inaccessible files can be treated as missing, bypassing warnings and strict system-wide failure.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

Backports tolerant handling for malformed or unreadable per-user PowerShell configuration while retaining strict system-wide behavior.

Changes:

  • Adds per-user fallback warnings for IO and JSON errors.
  • Adds localized warning resources.
  • Adds focused fallback and warning tests.
File Summary
test/​xUnit/​csharp/​test_PSConfiguration.cs Tests fallback and warning behavior.
src/​System.Management.Automation/​resources/​PSConfigurationStrings.resx Adds warning messages.
src/​System.Management.Automation/​engine/​PSConfiguration.cs Implements configuration fallback handling.

💡 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 8a32d84 into PowerShell:release/v7.5.12 Sep 23, 2026
36 checks passed
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) deleted the backport/release/v7.5.12/27373-84a930151 branch September 23, 2026 21:03
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