Powershell: New error view stuff blows up when a non-ErrorRecord is in $error

Created on 30 Dec 2019  路  6Comments  路  Source: PowerShell/PowerShell

And exceptions fail to display at all.

Steps to reproduce

Don't execute these in one single invocation; each line should be entered separately at the interactive prompt:

if foo
$error
$error.Count
$foo = $error[-1]
$foo
$error.Count

Expected behavior

The first line should yield an error, because "if foo" is not valid syntax. And then when we execute "$error" we should see the contents of the $error variable, which should be that same error. And then $error.Count should yield "1". And then when we assign that error into $foo, and then output $foo, we should see the error again. And $error.Count should stay 1.

Actual behavior

When $error is output, we get

InvalidOperation: An error occurred while enumerating through a collection: Collection was modified; enumeration operation may not execute..

And $error.Count is 4, not 1.

And then when we output $foo, get get... nothing. (well, a blank line)

And then $error.Count is 6.

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-rc.1
PSEdition                      Core
GitCommitId                    7.0.0-rc.1
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question Resolution-Answered

All 6 comments

I think @SteveL-MSFT recently submitted a PR to fix this one...

Yep! Was fixed in https://github.com/PowerShell/PowerShell/pull/11415 and should be in the daily build (and hopefully in GA). 馃檪

Thanks! I definitely hope this gets fixed for GA--it's enough trouble already when you have to deal with some sort of an exception, and a bug like this which greatly complicates the troubleshooting task is especially vexing.

Is there a place I can download a daily build, so that I don't have to build myself? (What I really need is the PowerShell SDK NuGet package; I'm trying to consume that in a separate project, and this Issue is a major impediment to investigating my own bugs.)

I can not repo on latest build.

@jazzdelightsme as far as I'm aware, the daily build is only compiled for the main PowerShell application project itself at the moment.

I'm not sure if there's a way to configure it to also build a version of the SDK that can be consumed by other applications; I'm sure that would help a lot of application developers get on top of new releases and be able to road-test things ahead of time. @TravisEz13 is there anything available for that use case?

I wouldn't object to someone handing me an easier way, but I was able to patch my local .nuget cache with a binary from here: https://powershell.visualstudio.com/PowerShell/_build/results?buildId=42139&view=artifacts&type=publishedArtifacts

I was worried that nuget would notice that hashes didn't match or something, but no--it seems to be letting me get away with it so far.

If you just want to test the daily build, you can use https://github.com/PowerShell/PowerShell/blob/master/tools/install-powershell.ps1:

iex "& { $(irm https://aka.ms/install-powershell.ps1) } -Daily"
GitHub
PowerShell for every system! Contribute to PowerShell/PowerShell development by creating an account on GitHub.
Was this page helpful?
0 / 5 - 0 ratings