GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix ErrorActionPreference not being respected from throw site when reset in finally block by rjmholt · Pull Request #15833 · PowerShell/PowerShell

Conversation

@rjmholt

@rjmholt Rob Holt (rjmholt) commented Jul 27, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

PR Summary

Fixes #15726.

When an error is thrown due to $ErrorActionPreference = 'Stop', we now mark it at the first opportunity to prevent having the action preference re-interpreted at a later stage (so that a finally block changing the value won't cause the error to be quietly downgraded).

Labelled as a breaking change because the existing behaviour is observable, but I think is a bucket-3 corner case behaviour that users would experience as a bug. Of note is that ordinary errors written with the WriteError() API will exhibit the correct behaviour, and this change just ensures that all other errors behave the same way.

PR Context

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: or [ WIP ] to the beginning of the title (the WIP bot will keep its status check at Pending while the prefix is present) and remove the prefix when the PR is ready.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
  • Tooling
    • I have considered the user experience from a tooling perspective and don't believe tooling will be impacted.
    • OR
    • I have considered the user experience from a tooling perspective and opened an issue in the relevant tool repository. This may include:
      • Impact on PowerShell Editor Services which is used in the PowerShell extension for VSCode
        (which runs in a different PS Host).
        • Issue filed:
      • Impact on Completions (both in the console and in editors) - one of PowerShell's most powerful features.
        • Issue filed:
      • Impact on PSScriptAnalyzer (which provides linting & formatting in the editor extensions).
        • Issue filed:
      • Impact on EditorSyntax (which provides syntax highlighting with in VSCode, GitHub, and many other editors).
        • Issue filed:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jazzdelightsme and vexx32 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@rjmholt Rob Holt (rjmholt) added WG-Engine core PowerShell engine, interpreter, and runtime Breaking-Change breaking change that may affect users labels Jul 27, 2021
@rjmholt
Rob Holt (rjmholt) requested review from James Truher (JamesWTruher), Steve Lee (SteveL-MSFT) and Dongbo Wang (daxian-dbw) July 27, 2021 18:04
@ghost ghost assigned Andrew (anmenaga) Jul 27, 2021
@rjmholt Rob Holt (rjmholt) assigned Aditya Patwardhan (adityapatwardhan) and unassigned Andrew (anmenaga) Jul 27, 2021
iSazonov
Ilya (iSazonov) reviewed Jul 28, 2021
View reviewed changes
Comment thread test/powershell/Language/Scripting/ActionPreference.Tests.ps1 Resolved

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost added the Review - Needed The PR is being reviewed label Aug 5, 2021
@ghost

Deleted user (ghost) commented Aug 5, 2021

Copy link
Copy Markdown

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Rob Holt (rjmholt) added 5 commits August 9, 2021 15:27
@rjmholt
Make semantics change
185e38a
@rjmholt
Improve style
7fdfc14
@rjmholt
Add tests
034b732
@rjmholt
Fix test
3e7a8e4
@rjmholt
Add further testing
fe52ad8
@rjmholt
Rob Holt (rjmholt) force-pushed the fix-eap-nonstop branch from 6407f94 to fe52ad8 Compare August 9, 2021 22:27
iSazonov
Ilya (iSazonov) reviewed Aug 10, 2021
View reviewed changes
Comment thread test/powershell/Language/Scripting/ActionPreference.Tests.ps1 Outdated
try
{
$oldEAP = $ErrorActionPreference
$ErrorActionPreference = 'Stop'

@iSazonov Ilya (iSazonov) Aug 10, 2021

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The test name says nothing about "Stop". Make sense to have tests for all possible ErrorActionPreference values?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iSazonov Ilya (iSazonov) added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log labels Aug 10, 2021
@rjmholt
Expand tests
b94f1af
@rjmholt

Rob Holt (rjmholt) commented Aug 10, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

So looking through the behaviour here, it looks like something deeper is still happening in an unexpected way. Compare:

> get-process -banana; write-host 'hello'
Get-Process: A parameter cannot be found that matches parameter name 'banana'.
hello
> try { get-process -banana; write-host 'hello' } catch { }
# No output here

Parameter binding seems to create a non-terminating error that can be caught...

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost removed the Review - Needed The PR is being reviewed label Aug 10, 2021
@rjmholt
Rob Holt (rjmholt) marked this pull request as draft August 10, 2021 17:44
@rjmholt

Rob Holt (rjmholt) commented Aug 10, 2021

Copy link
Copy Markdown
Collaborator Author

Going to mark this for Working Group review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rjmholt Rob Holt (rjmholt) mentioned this pull request Aug 13, 2021
Add more tests to validate the current command error handling behaviors #15919
Merged
8 tasks done
@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Aug 13, 2021
@ghost ghost added the Stale label Aug 28, 2021
@ghost

Deleted user (ghost) commented Aug 28, 2021

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ghost ghost closed this Sep 8, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov left review comments
@daxian-dbw Dongbo Wang (daxian-dbw) Awaiting requested review from daxian-dbw
@JamesWTruher James Truher (JamesWTruher) Awaiting requested review from JamesWTruher
@SteveL-MSFT Steve Lee (SteveL-MSFT) Awaiting requested review from SteveL-MSFT
Copilot code review Copilot
Copilot will automatically review once the pull request is marked ready for review

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@adityapatwardhan Aditya Patwardhan (adityapatwardhan)

Labels

Breaking-Change breaking change that may affect users CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Stale Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept WG-Engine core PowerShell engine, interpreter, and runtime

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

setting error action preference in finally clause affects terminating parameter binding errors

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@rjmholt @iSazonov @anmenaga @adityapatwardhan
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.