Skip to content

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

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

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

Conversation

@adityapatwardhan

Copy link
Copy Markdown
Member

Backport of #27373 to release/v7.6.7

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 PowerShell can fail during startup when the per-user powershell.config.json is unreadable because a cloud file provider such as OneDrive is not running, access is denied, JSON is malformed, or a value has the wrong shape. Expected behavior is a warning and fallback to default current-user settings; system-wide configuration errors remain hard failures.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

The original PR added xUnit coverage for malformed and unreadable current-user configuration files, type-mismatched values, fallback-to-default behavior, warning emission to stderr, and continued strict failure for the all-users configuration. The backport cherry-picked cleanly onto the latest upstream release/v7.6.7; the worktree is clean, the branch is exactly one commit ahead of the target, and git diff --check passed. CI will provide release-branch build and test validation.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Medium risk because this changes early-startup configuration handling in the engine. The change is scoped to current-user configuration failures, preserves fail-closed behavior for the security-relevant all-users configuration, and includes focused xUnit coverage for both fallback paths and warning output.

Copilot AI lite review requested due to automatic review settings September 24, 2026 05:08
@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 24, 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

Unresolved handling and test coverage gaps affect the promised behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This backport makes per-user configuration errors non-fatal while preserving strict system-wide configuration handling.

Changes:

  • Adds fallback warnings for current-user configuration failures.
  • Adds localized warning messages.
  • Adds regression coverage for fallback behavior.

Unresolved issues remain around unreadable-file warning behavior and coverage for I/O and security-sensitive configuration cases.

File Summary
test/​xUnit/​csharp/​test_PSConfiguration.cs Adds configuration fallback and warning tests.
src/​System.Management.Automation/​resources/​PSConfigurationStrings.resx Adds localized fallback warning messages.
src/​System.Management.Automation/​engine/​PSConfiguration.cs Implements tolerant current-user configuration loading.

💡 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 b613dd7 into PowerShell:release/v7.6.7 Sep 24, 2026
44 of 46 checks passed
@adityapatwardhan
Aditya Patwardhan (adityapatwardhan) deleted the backport/release/v7.6.7/27373-84a930151 branch September 24, 2026 17:15
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.

3 participants