Skip to content

REPL loop error, index out of range, must be non negative #1642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ninmonkey opened this issue Dec 5, 2021 · 8 comments
Closed

REPL loop error, index out of range, must be non negative #1642

ninmonkey opened this issue Dec 5, 2021 · 8 comments
Assignees
Labels
Issue-Bug A bug to squash.
Milestone

Comments

@ninmonkey
Copy link

ninmonkey commented Dec 5, 2021

About

Some regular errors are trigging this exception from editor services. The exact same code outside of vscode throws a parameter binding error like normal. It seems like there's a regular error, for a failed parameter binding, which is triggering an EditorServices crash/error

An error occurred while running the REPL loop:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

image

Notes or Ideas

  • I started new windows, and respawned the PSIT to see if it was a one-off or not.
  • It is not specific to ConvertFrom-LiteralPath , it seems to occur on functions with Write-Error, but not all of them
  • inside vscode PSIT /w PSES it throws the REPL exception
  • code outside in wt throws just the parameter binding error.
  • the REPL exception "consumes" the real error, the parameter
  • The filepaths show drive d:\, I'm wondering if that's a path to one of the developers ? I have no d:\a\ directory
  • When reproducing with a minimal example, it seemed like if the function was in a module, then the REPL error would throw
  • Exact same code, outside of a module, didn't seem to work
  • Sometimes it seemed like Write-Error -ea Continue caused the REPL exception, verses stop or implicit
in D:\a\1\s\src\PowerShellEdi 
                 torServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120" value of   
                 type "System.Management.Automation.ActionPreferenceStopException" to type "System.Int32".   
TargetSite     : System.Object ThrowInvalidCastException(System.Object, System.Type)
Message        : Cannot convert the "System.Management.Automation.ActionPreferenceStopException: The
                 running command stopped because the preference variable "ErrorActionPreference" or common   
                 parameter is set to Stop: Cannot bind argument to parameter 'LiteralPath' because it is an  
                 empty string.
  • Is casting [Exception] as [int] normal ?

Code

I simplified the cause down to a single write-error. It triggered when imported from a module verses dotsourced externally.

function ConvertFrom-LiteralPath {
    <#
    .synopsis
        transform literal paths back into an EnvironmentVariable path
    #>
    [cmdletbinding()]
    param (
        # input LiteralPath to convert
        [Parameter(Mandatory, Position = 0, ValueFromPipeline)][string]$LiteralPath
    )
    begin {}
    process {
        Write-Error 'No matches'
    }
    end {}
}

Expected Behavior

PS> '' | BugFrom-LiteralPath
BugFrom-LiteralPath: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.

image

Actual Behavior

Run

'' | ConvertFrom-LiteralPath

Output

An error occurred while running the REPL loop:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')       
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.MergePipelineResults(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 62
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.AddOutputCommand(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 45
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.Run(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 55
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteSynchronously(CancellationToken executorCancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 104
--- End of stack trace from previous location ---
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.get_Result() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 60
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeInput(String input, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 682
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.DoOneRepl(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 654

Log

Warn  - 6:26:59 PM] Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: Runtime exception occurred while executing command:

System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[TResult](PowerShell pwsh, PSInvocationSettings invocationSettings) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 50
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120 | 
[Error - 6:26:59 PM] Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: An error occurred while running the REPL loop - System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.MergePipelineResults(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 62
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.AddOutputCommand(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 45
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.Run(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 55
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteSynchronously(CancellationToken executorCancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 104
--- End of stack trace from previous location ---
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.get_Result() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 60
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeInput(String input, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 682
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.DoOneRepl(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 654 | 

Environment

Name Version
code 1.63.0-insider, 0cc0904c565399781defa830facf43141db8b6f3, x64
PSVersionTable within PSIT 7.2.0
Installed Addon Version
justin-grote.powershell-extension-pack 0.0.5
ms-vscode.powershell-preview 2021.11.1
ms-vscode.test-adapter-converter 0.1.4
pspester.pester-test 2021.10.2
TylerLeonhardt.vscode-inline-values-powershell 0.0.5
TylerLeonhardt.vscode-pester-test-adapter 0.0.23
Module Version
EditorServicesCommandSuite 1.0.0
Pansies 2.3.1
posh-git 1.0.0
PowerShellEditorServices.Commands 0.2.0
PowerShellEditorServices.VSCode 0.2.0
PSReadLine 2.2.0

Logs

About

Some regular errors are trigging this exception from editor services. The exact same code outside of vscode throws a parameter binding error like normal. It seems like there's a regular error, for a failed parameter binding, which is triggering an EditorServices crash/error

An error occurred while running the REPL loop:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

image

Notes or Ideas

  • I started new windows, and respawned the PSIT to see if it was a one-off or not.
  • It is not specific to ConvertFrom-LiteralPath , it seems to occur on functions with Write-Error, but not all of them
  • inside vscode PSIT /w PSES it throws the REPL exception
  • code outside in wt throws just the parameter binding error.
  • the REPL exception "consumes" the real error, the parameter
  • The filepaths show drive d:\, I'm wondering if that's a path to one of the developers ? I have no d:\a\ directory
  • When reproducing with a minimal example, it seemed like if the function was in a module, then the REPL error would throw
  • Exact same code, outside of a module, didn't seem to work
  • Sometimes it seemed like Write-Error -ea Continue caused the REPL exception, verses stop or implicit
in D:\a\1\s\src\PowerShellEdi 
                 torServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120" value of   
                 type "System.Management.Automation.ActionPreferenceStopException" to type "System.Int32".   
TargetSite     : System.Object ThrowInvalidCastException(System.Object, System.Type)
Message        : Cannot convert the "System.Management.Automation.ActionPreferenceStopException: The
                 running command stopped because the preference variable "ErrorActionPreference" or common   
                 parameter is set to Stop: Cannot bind argument to parameter 'LiteralPath' because it is an  
                 empty string.
  • Is casting [Exception] as [int] normal ?

Code

I simplified the cause down to a single write-error. It triggered when imported from a module verses dotsourced externally.

function ConvertFrom-LiteralPath {
    <#
    .synopsis
        transform literal paths back into an EnvironmentVariable path
    #>
    [cmdletbinding()]
    param (
        # input LiteralPath to convert
        [Parameter(Mandatory, Position = 0, ValueFromPipeline)][string]$LiteralPath
    )
    begin {}
    process {
        Write-Error 'No matches'
    }
    end {}
}

Expected Behavior

PS> '' | BugFrom-LiteralPath
BugFrom-LiteralPath: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.

image

Actual Behavior

Run

'' | ConvertFrom-LiteralPath

Output

An error occurred while running the REPL loop:
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')       
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.MergePipelineResults(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 62
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.AddOutputCommand(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 45
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.Run(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 55
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteSynchronously(CancellationToken executorCancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 104
--- End of stack trace from previous location ---
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.get_Result() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 60
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeInput(String input, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 682
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.DoOneRepl(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 654

Log

Warn  - 6:26:59 PM] Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: Runtime exception occurred while executing command:

System.Management.Automation.ActionPreferenceStopException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Cannot bind argument to parameter 'LiteralPath' because it is an empty string.
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, PSInvocationSettings settings)
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Utility.PowerShellExtensions.InvokeAndClear[TResult](PowerShell pwsh, PSInvocationSettings invocationSettings) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Utility\PowerShellExtensions.cs:line 50
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120 | 
[Error - 6:26:59 PM] Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost: An error occurred while running the REPL loop - System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.MergePipelineResults(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 62
   at Microsoft.PowerShell.EditorServices.Utility.PSCommandExtensions.AddOutputCommand(PSCommand psCommand) in D:\a\1\s\src\PowerShellEditorServices\Utility\PSCommandExtensions.cs:line 45
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteNormally(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 120
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.Run(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 55
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteSynchronously(CancellationToken executorCancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 104
--- End of stack trace from previous location ---
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.get_Result() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 60
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeInput(String input, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 682
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.DoOneRepl(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 654 | 

Environment

Name Version
code 1.63.0-insider, 0cc0904c565399781defa830facf43141db8b6f3, x64
PSVersionTable within PSIT 7.2.0
Installed Addon Version
justin-grote.powershell-extension-pack 0.0.5
ms-vscode.powershell-preview 2021.11.1
ms-vscode.test-adapter-converter 0.1.4
pspester.pester-test 2021.10.2
TylerLeonhardt.vscode-inline-values-powershell 0.0.5
TylerLeonhardt.vscode-pester-test-adapter 0.0.23
Module Version
EditorServicesCommandSuite 1.0.0
Pansies 2.3.1
posh-git 1.0.0
PowerShellEditorServices.Commands 0.2.0
PowerShellEditorServices.VSCode 0.2.0
PSReadLine 2.2.0

Logs

@ghost ghost added the Needs: Triage Maintainer attention needed! label Dec 5, 2021
@ninmonkey
Copy link
Author

ninmonkey commented Dec 5, 2021

Somewhere I saw it mentioned that the term was & executing instead of dot-sourceing, maybe that explains the scope issues?

maybe related

  • my prompt can read my errors scope
  • It's strange, my prompt can't access a variable in the PSIT, but outside it can
  • if I move the PSIT tab around, some positions it goes blank, until moved elsewhere.
  • it was executing code that no longer existed
  • when execute ending, sometimes the colors flash to a different prompt or charset, it's fast.

It'd be running fine, but, at some point I found it would get stuck -- running cached code instead. I tested it by creating a function that runs. Next I added a throw, and the function stays on the stale version, so it throws nothing

function foo {
   throw "bad
}
foo

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 5, 2021
@ninmonkey
Copy link
Author

Maybe the REPL error is a red herring? Maybe it's not exactly a bug, just an error record either getting wrapped or not getting wrapped, so it appears it's a crash? Because $global:error[0] shows different error information.

Correct Error Just Not Bubbling?

It seems to be caused by a legitimate/correct error being thrown, that's getting consumed by editorservices or PSReadLine instead of bubbling to the user? Like this:

[Globalization.CharUnicodeInfo]::GetUnicodeCategory('a')

MethodException: Cannot convert argument "codePoint", with v
alue: "a", for "GetUnicodeCategory" to type "System.Int32":
"Cannot convert value "a" to type "System.Int32". Error: "In
put string was not in a correct format.""
  • In one way it's really deterministic, like if you find some code has the error, it'll happen every time if you repeat it.
  • But if you make a brand new window, the same code, it may not occur occur. But it can show up other places.

It seems to happen more often under these conditions

  • after you've ran a few debugger runs
  • while in a breakpoint, you're entering some code in the REPL / PSIC
  • maybe doesn't occur unless until you've used wait-debugger once
  • Inside a loop
  • function is inside a module
  • Once I move it to a script, it's hard to reproduce it

Is "text".GetEnumerator() ever unsafe to enumerate over?

image

image

sample

This is the code that was triggering the REPL error when inside a module, but not when outside. It's possible the specific code doesn't matter, rather it's any exception thrown ?

#Requires -Version 7
using namespace system.Text


function Inspect-Rune {
    <#
    #>
    [CmdletBinding(PositionalBinding = $false)]
    param(
        # any text
        [Parameter(Position = 0, Mandatory, ValueFromPipeline)]
        [string]$InputText
    )
    begin {
        $str = @{
            Null       = '[null]'
            NullSymbol = "`u{2400}"
        }
        $Simplify = $false
    }
    process {
        $InputText.EnumerateRunes()
        | ForEach-Object {
            $rune = $_
            $meta = [ordered]@{
                PSTypeName  = 'nin.RuneDetail'
                CodeHex     = '0x{0:x}' -f $Rune.Value
                UniCategory = [Rune]::GetUnicodeCategory( $Rune )
            }
            if ($meta.UniCategory -match 'control' ) {
                $meta['Render'] = [rune]::new( $Rune.Value + 0x2400 )
            } else {
                $meta['Render'] = "'$Rune'"
            }
            Wait-Debugger

            if (!$Simplify) {
                $meta += @{
                    # PwshLiteral = $Rune | ConvertTo-PwshLiteral
                    CodePoint       = $Rune.Value
                    GI_Category     = [Globalization.CharUnicodeInfo]::GetUnicodeCategory( $_.Value )
                    GI_DecimalDigit = [Globalization.CharUnicodeInfo]::GetDecimalDigitValue( $_.Value )
                    GI_DigitValue   = [Globalization.CharUnicodeInfo]::GetDigitValue( $_.Value )
                    GI_NumericValue = [Globalization.CharUnicodeInfo]::GetNumericValue( $_.Value )

                }

            }
            [PSCustomObject]$meta
        }
    }
    end {

    }
}

'😃' | Inspect-Rune
'👩🏼‍🦳' | Inspect-Rune

@andyleejordan andyleejordan self-assigned this Dec 17, 2021
@andyleejordan andyleejordan added this to the Committed milestone Dec 17, 2021
@andyleejordan andyleejordan added Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! Needs: Maintainer Attention Maintainer attention needed! labels Dec 17, 2021
@andyleejordan
Copy link
Member

@ninmonkey Justin and I solved an index out of range exception that was happening, and I resolved the scoping regression by moving back to dot-source instead of ampersand-call. Can you test the latest preview released yesterday to see if these issues have been resolved? Thanks!

@ninmonkey
Copy link
Author

@andschwa I tried the latest insider with both extensions.
It looks good.

extension build
ms-vscode.powershell ✅ v2021.12.0
ms-vscode.powershell-preview ✅ v2022.1.0
Version: 1.64.0-insider
Commit: 753319a08f8e74700b1dba3a29bf0a6af7c2953f

I'm getting the (expected) errors, ex:

"Cannot convert value "128515" to type "System.Char".

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 13, 2022
@andyleejordan
Copy link
Member

Fantastic, thanks for confirming!

@andyleejordan andyleejordan added Status: Fixed and removed Needs: Maintainer Attention Maintainer attention needed! labels Jan 13, 2022
@JustinGrote
Copy link
Collaborator

JustinGrote commented Jan 19, 2022

@andschwa Sadly I just hit this in Pester on v2022.1.0 while debugging. I'll try to get a better repro together.

EDIT: Only seems to trigger in debug, non-debug it doesn't happen.

image

An error occurred while running the REPL loop:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Debugging.PowerShellDebugContext.ProcessDebuggerResult(DebuggerCommandResults debuggerResult) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Debugging\PowerShellDebugContext.cs:line 154
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.ExecuteInDebugger(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 196
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousPowerShellTask`1.Run(CancellationToken cancellationToken) in
D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousPowerShellTask.cs:line 55
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteSynchronously(CancellationToken executorCancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 104
--- End of stack trace from previous location ---
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.get_Result() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 60
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Execution.SynchronousTask`1.ExecuteAndGetResult(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Execution\SynchronousTask.cs:line 109
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokePSCommand[TResult](PSCommand psCommand, PowerShellExecutionOptions executionOptions, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 371
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokePSCommand(PSCommand psCommand, PowerShellExecutionOptions executionOptions, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 375
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.InvokeInput(String input, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 678
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.DoOneRepl(CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 640

Script Used

Describe 'ConvertTo-ReliefJetPST' {
    BeforeAll {
        Import-Module $PSScriptRoot/PSTMigration.psm1 -Force
        $SCRIPT:Mocks = Resolve-Path (Join-Path $PSScriptRoot $PSTMigration.Mocks)
    }
    It 'Folder with MSG files, different destination' {

        $MockSource = Join-Path $Mocks 'FolderWithMsgFile'
        $MockSource
        | ConvertTo-ReliefJetPST -Destination 'TestDrive:/'
    }
}

@JustinGrote JustinGrote reopened this Jan 19, 2022
@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 19, 2022
@andyleejordan
Copy link
Member

@JustinGrote That stack traces points to here:

public void ProcessDebuggerResult(DebuggerCommandResults debuggerResult)
{
if (debuggerResult.ResumeAction is not null)
{
SetDebugResuming(debuggerResult.ResumeAction.Value);
RaiseDebuggerResumingEvent(new DebuggerResumingEventArgs(debuggerResult.ResumeAction.Value));
}
}

Which means somehow debuggerResult is null. I guess it should just be debuggerResult?.ResumeAction.

@andyleejordan
Copy link
Member

Actually, @JustinGrote could you please open a new issue instead and close this? The stacktrace you shared indicates a different bug. And test #1670 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

3 participants