Skip to content

Fix inconsistent newline stripping in ConciseView (#24108)#27160

Open
reabr wants to merge 8 commits into
PowerShell:masterfrom
reabr:fix/issue-24108-conciseview-newlines
Open

Fix inconsistent newline stripping in ConciseView (#24108)#27160
reabr wants to merge 8 commits into
PowerShell:masterfrom
reabr:fix/issue-24108-conciseview-newlines

Conversation

@reabr
Copy link
Copy Markdown
Contributor

@reabr reabr commented Apr 2, 2026

Summary

Fixes inconsistent newline handling in $ErrorView = 'ConciseView' where multi-line error messages were sometimes collapsed to a single line and sometimes preserved, depending on whether the error originated from a direct function call or a wrapper/module call.

Problem

In ConciseView, the code that strips \r\n and \n from error messages was wrapped inside a conditional block:

if ($myinv -and $myinv.ScriptName -or $err.CategoryInfo.Category -eq 'ParserError') {
    $message = $message.Replace($newline, ' ').Replace("`n", ' ').Replace("`t", ' ')
}

@reabr reabr requested a review from a team as a code owner April 2, 2026 20:50
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Review - Needed The PR is being reviewed label Apr 10, 2026
@reabr
Copy link
Copy Markdown
Contributor Author

reabr commented Apr 26, 2026

Hi team 👋 Just checking in is there anything I can do to help move this forward?
Happy to adjust the fix, add tests, or clarify the change if needed. Thanks!

Copilot AI review requested due to automatic review settings May 2, 2026 17:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes inconsistent $ErrorView = 'ConciseView' formatting so multiline error messages are normalized the same way regardless of whether the error comes from a direct script invocation or a wrapper/module path. It updates the core formatter logic that builds concise error output in System.Management.Automation.

Changes:

  • Moves newline/tab normalization so it runs for all ConciseView messages, not only when line details are shown.
  • Preserves the existing line-wrapping branch for script/parser errors after the message has been normalized.

@azure-pipelines
Copy link
Copy Markdown

There was an error handling pipeline event b86f760d-f17a-4b02-93fa-0251da0ef538.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review - Needed The PR is being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants