Open
@eitamal

Description

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

When you try starting PSES by calling Start-EditorServices.ps1 with a Microsoft.Extensions.Logging log level value, if it doesn't match one of the legacy log levels you get an error, e.g.:

19:22:57 ❯ pwsh -nol -nop -Command "& '$PWD/PowerShellEditorServices/Start-EditorServices.ps1' -BundledModulesPath '$PWD' -LogPath '$PWD/powershell_es.log' -SessionDetailsPath '$HOME/.cache/nvim/powershell_es.session.json' -FeatureFlags @() -AdditionalModules @() -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -Stdio -LogLevel Information"
Start-EditorServices.ps1: Cannot validate argument on parameter 'LogLevel'. The argument "Information" does not belong to the set "Diagnostic,Verbose,Normal,Warning,Error" specified by the ValidateSet attribute. Supply an argument that is in the set
and then try the command again.

As you can see, it's expecting one of the legacy log levels: Diagnostic, Verbose, Normal, Warning, Error, while the MEL log level defines: Trace, Debug, Information, Warning, Error, Critical, None.

So these are the log levels missing from the validation (the one defined here Start-EditorServices.ps1:49):

  • Trace
  • Debug
  • Information
  • Critical
  • None

I believe this was introduced while making the changes for #2200 and this spot was simply missed. Also, I think the legacy log levels should be kept while a clear cut hasn't been made, for compatibility reasons - as noted here:

PSES used to have log levels that didn't match MEL levels, this is an adapter for those types and may eventually be removed once people migrate their settings.

If you'd like to reproduce the error, you just need to pass one of the log levels mentioned via -LogLevel, you can also use my command above, or you can use the one in the readme for Advanced Usage, since it uses Trace for the log level.

Workaround

Warning and Error can be used as is. For the rest of them, the code has the following mapping:

MEL (New)Legacy
TraceDiagnostic
DebugVerbose
InformationNormal
CriticalN/A
NoneN/A

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.1
PSEdition                      Core
GitCommitId                    7.5.1
OS                             Ubuntu 22.04.5 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Editor Version

NVIM v0.12.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.1744317938
Compilation: /usr/bin/cc -O2 -g -flto -fno-fat-lto-objects -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-s -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-s -fsigned-char -fstack-protector-strong -Wno-conversion -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always  -DUNIT_TESTING -D_GNU_SOURCE -DINCLUDE_GENERATED_DECLARATIONS -DUTF8PROC_STATIC -I~/.local/share/mise/downloads/neovim/ref-nightly/.deps/usr/include/luajit-2.1 -I~/.local/share/mise/downloads/neovim/ref-nightly/.deps/usr/include -I~/.local/share/mise/downloads/neovim/ref-nightly/build/src/nvim/auto -I~/.local/share/mise/downloads/neovim/ref-nightly/build/include -I~/.local/share/mise/downloads/neovim/ref-nightly/build/cmake.config -I~/.local/share/mise/downloads/neovim/ref-nightly/src -I/usr/include 

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

PowerShell Editor Services Version

-

Steps to Reproduce

pwsh -nol -nop -Command "./PowerShellEditorServices/Start-EditorServices.ps1 -SessionDetailsPath ./session.json -LogLevel Information"

Visuals

No response

Logs

No response