shellIntegration.ps1
adds additional errors to $Error
variable when errors occur #235298
Open
Description
opened on Dec 4, 2024
Env info
- VS Code Version: 1.95.3
- OS Version: Windows 11 24H2 x64
- PowerShell version: v7.4.6 x64
- Extension: PowerShell v2024.0
Reproduce
In a PowerShell Extension terminal, do:
# Clear error
$Error.Clear()
# Invoke request known to fail
$null = Invoke-RestMethod -Method 'Post' -Uri 'https://graph.microsoft.com' -Body @{'test' = [string]'test'}
# Count errors, should be 1 but is 3
$Error.Count
I then found out by looking at $Error[0]
that one of the errors were added by VSCode shellIntegration.ps1
.
PS > $Error[0].InvocationInfo
MyCommand : Select-Object
BoundParameters : {}
UnboundArguments : {}
ScriptLineNumber : 218
OffsetInLine : 64
HistoryId : 55
ScriptName :
Line : $global:Error[0] | Where-Object { $_ -ne $null } | Select-Object -ExpandProperty InvocationInfo
Statement : Select-Object -ExpandProperty InvocationInfo
PositionMessage : At line:218 char:64
+ … bject { $_ -ne $null } | Select-Object -ExpandProperty InvocationInfo
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot :
PSCommandPath :
InvocationName : Select-Object
PipelineLength : 0
PipelinePosition : 0
ExpectingInput : False
CommandOrigin : Internal
DisplayScriptPosition :
PS > $Error[0].ScriptStackTrace
at Update-PoshErrorCode, <No file>: line 218
at <ScriptBlock>, <No file>: line 272
at Global:Prompt, C:\Program Files\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1: line 96
PS >
Could find shellIntegration.ps1
, but I can't find that invocation line in it.
Doing the same in "vanilla" pwsh -NoProfile
only adds one error to the $Error
variable:
PowerShell 7.4.6
PS > $null = Invoke-RestMethod -Method 'Post' -Uri 'https://graph.microsoft.com' -Body @{'test' = [string]'test'}
Invoke-RestMethod: Response status code does not indicate success: 405 (Method Not Allowed).
PS > $Error.Count
1
PS >
Activity