PowerShell/PowerShellEditorServices

[Preview Build] SortHierarchicalSymbolsImpl throwing on "We didn't find the child's parent!"

Opened this issue · 1 comments

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
  • I have verified that I am using the latest version of PowerShell Editor Services.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Started having a crash in PSES on startup, not sure what's going on here, will investigate. More importantly, the exception didn't get written to the log, I had to flash-capture it from the console.

❯ Process terminated. Assertion failed.
We didn't find the child's parent!
   at Microsoft.PowerShell.EditorServices.Handlers.PsesDocumentSymbolHandler.SortHierarchicalSymbolsImpl(List`1 symbols, CancellationToken cancellationToken) in D:\PowerShellEditorServices\src\PowerShellEditorServices\Services\TextDocument\Handlers\DocumentSymbolHandler.cs:line 87
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()

PowerShell Editor Services Version

HotReload Preview Build

Well now I can't reproduce it, @andyleejordan something to bang on. I was assisting with @tabs-not-spaces and had code something like this.

function Get-ProjectAccess {
    [cmdletbinding()]
    param(
        [parameter(Mandatory = $true)]
        [ArgumentCompleter({
            param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
            $script:Configuration = $script:Configuration ?? $(Get-EnvironmentConfiguration)
            Invoke-ProjectNameCompleter -WordToComplete $wordToComplete
        })]
        [string]$Project,

        [parameter(Mandatory = $true)]
        [string[]]$Database,

        [parameter(Mandatory = $false)]
        [ValidateSet('Read', 'ReadWrite')]
        [string]$AccessLevel = 'Read',

        [parameter(Mandatory = $false)]
        [ValidateRange(1, 12)]
        [int]$DeleteAfterHours = 2
    )
    try {
        $newUser = @{
            UserName         = "$($env:USER ?? $env:USERNAME)_Temp"
            Password         = (New-Guid).Guid
            DeleteAfterHours = $DeleteAfterHours
            Databases        = $(foreach ($db in $Database) { New-DbAccess -Project $Project -Database $db -AccessLevel $AccessLevel })
        }
        ## Send the request to the database api - we don't know how this works yet, so let's just display the request data.
        return $($newUser | ConvertTo-Json -Depth 10)
    }
    catch {
        Write-Warning $_.Exception.Message
    }
}