Vscode-powershell: Extension doesn't start up when `files.exclude` values are non-boolean

Created on 24 Apr 2020  路  15Comments  路  Source: PowerShell/vscode-powershell

Powershell integrated console hangs on when I open powershel source file. Running any powershell code by pressing F5 also hangs on.

Attach output console log, terminal window screenshot and logs.
ms-vscode.powershell-logs.zip
terminal-window-log.txt
vscode-output-log.txt
vscode-terminal-window

Area-Configuration Area-Startup Issue-Bug Up-for-Grabs

Most helpful comment

I'm running into this issue as well when using the following settings:

    "files.exclude": {
        "**/__pycache__": true,
        "**/*.pyc": {
            "when": "$(basename).py"
        }
    },

Since it's just a QOL setting, I've removed it to make it work.

All 15 comments

Do you have any privilege management software or antivirus software installed on this machine? We've heard reports that these slow down start up...

No.

@BooTheHamster thanks for the logs could you please also provide any settings you have in vscode?

PS C:\Work\bin> code --list-extensions
adrianwilczynski.namespace
alefragnani.numbered-bookmarks
christian-kohler.path-intellisense
cyrilletuzi.angular-schematics
dawidd6.debian-vscode
dsznajder.es7-react-js-snippets
edag94.replacequotes
eternalphane.tsfmt-vscode
fknop.vscode-npm
heaths.vscode-guid
jchannon.csharpextensions
jmrog.vscode-nuget-package-manager
k--kato.docomment
Mikael.Angular-BeastCode
mike-co.import-sorter
MikeBovenlander.formate
ms-dotnettools.csharp
ms-python.python
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode-remote.vscode-remote-extensionpack
ms-vscode.powershell
ms-vscode.vscode-typescript-tslint-plugin
msjsdiag.debugger-for-chrome
Shan.code-settings-sync
steoates.autoimport
vscode-icons-team.vscode-icons
wayou.vscode-todo-highlight
zhouronghui.propertylist
Zignd.html-css-class-completion

settings.txt

@BooTheHamster can you explain this line in your settings?

"**/*.js": { "when": "$(basename).ts"} in files.exclude...

I think if you remove that, you won't see this issue.

Looks like this is an (as far as I can tell) undocumented but used syntax. In order to accommodate it we'll need to either make parsing it fail nicely or implement a custom JSON parser for it

can you explain this line in your settings?

Old settings to hide *.js files when correcponding *.ts file exists.

@TylerLeonhardt thanks, I remove this settings and issue gone.

I've reopened this to track us handling this setting better.

I'm running into this issue as well when using the following settings:

    "files.exclude": {
        "**/__pycache__": true,
        "**/*.pyc": {
            "when": "$(basename).py"
        }
    },

Since it's just a QOL setting, I've removed it to make it work.

I also get the failure with the following files.exclude settings:

    "files.exclude": {
        "**/*.pyc": {"when": "$(basename).py"}, 
        "**/__pycache__": true
    },

The first of those settings will hide compiled Python 2 output files _as long as the corresponding *.py file is present_ (but if you delete or rename the original file, then the *.pyc file will show up in the File Explorer pane). The second of those settings hides the directory where Python 3 compiled output is stored.

Below are the exception and call stack reported in the PowerShell Editor Services output pane. Looks like the problem might originate near ConfigurationHandler.cs line 52?

[Error - 1:56:34 PM] OmniSharp.Extensions.JsonRpc.InputHandler: Failed to handle request workspace/didChangeConfiguration - Newtonsoft.Json.JsonReaderException: Error reading boolean. Unexpected token: StartObject. Path 'files.exclude['*/.pyc']'.
at Newtonsoft.Json.JsonReader.ReadAsBoolean()
at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObjectT
at Microsoft.PowerShell.EditorServices.Handlers.PsesConfigurationHandler.Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\Handlers\ConfigurationHandler.cs:line 52
at MediatR.Pipeline.RequestExceptionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestExceptionActionProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestPostProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at MediatR.Pipeline.RequestPreProcessorBehavior2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate1 next)
at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteNotification(TDescriptor descriptor, Notification notification, CancellationToken token)
at OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass39_0.<b__4>d.MoveNext() | Method='workspace/didChangeConfiguration'

Thanks for the extra info. We have a good idea where the problem is:

https://github.com/PowerShell/PowerShellEditorServices/blob/03373ae00cf1730da48d31cfa4c48c359d2952b1/src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs#L407-L431

See the use of Dictionary<string, bool>... that doesn't get deserialized correctly when we get "**/*.pyc": {"when": "$(basename).py"}

Not sure if @david-driscoll has any ideas here on the best way to handle this... but we probably need this to be a Dictionary of <string, BoolOrWhen> where BoolOrWhen is a class:

class BoolOrWhen
{
    public bool HasBool => _boolValue != null;
    private bool? _boolValue;
    public bool Bool => _boolValue ?? false;

    public bool HasWhen => When != null;
    public string When { get; private set; }
}

and then we have a Newtonsoft serializer that will handle turning what's given into this class.

With all that said... we've got a lot on our plate right now so this isn't the highest priority issue, unfortunately. If someone wants to help out and pick this up, we can probably be able to assist in walking through this.

I observed this issue today and spent a few hours trying to get my debugger to connect.

I modifed settings.json from:

{
  "files.exclude": {
    "amplify/.config": true,
    "amplify/**/*-parameters.json": true,
    "amplify/**/amplify.state": true,
    "amplify/**/transform.conf.json": true,
    "amplify/#current-cloud-backend": true,
    "amplify/backend/amplify-meta.json": true,
    "amplify/backend/awscloudformation": true,
    "**/.git": true,
    "**/.DS_Store": true,
    "**/*.js": {
      "when": "$(basename).ts"
    },
    "**/*.d.ts": {
      "when": "$(basename).ts"
    }
  },
  "deepscan.enable": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.markdownlint": true,
    "source.fixAll.eslint": true
  }
}

to (commenting out the causative issue)

{
  "files.exclude": {
    "amplify/.config": true,
    "amplify/**/*-parameters.json": true,
    "amplify/**/amplify.state": true,
    "amplify/**/transform.conf.json": true,
    "amplify/#current-cloud-backend": true,
    "amplify/backend/amplify-meta.json": true,
    "amplify/backend/awscloudformation": true,
    "**/.git": true,
    "**/.DS_Store": true,
    // "**/*.js": {
    //   "when": "$(basename).ts"
    // },
    // "**/*.d.ts": {
    //   "when": "$(basename).ts"
    // }
  },
  "deepscan.enable": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.markdownlint": true,
    "source.fixAll.eslint": true
  }
}

My logs (EditorServices.log) whilst this was broken looked like follows

2021-02-26聽11:26:12.706聽+01:00聽[INF]聽PowerShell聽runtime聽version:聽5.1.19041.610,聽edition:聽Desktop
2021-02-26聽11:26:13.446聽+01:00聽[INF]聽highlight聽handler聽loaded
2021-02-26聽11:26:13.980聽+01:00聽[ERR]聽Execution聽of聽the聽following聽command(s)聽completed聽with聽errors:
聽聽聽聽Import-Module聽~\.vscode\extensions\ms-vscode.powershell-2021.2.2\modules\PowerShellEditorServices\Commands\PowerShellEditorServices.Commands.psd1

2021-02-26聽11:26:14.892聽+01:00聽[FTL]聽Failed聽to聽handle聽request聽workspace/didChangeConfiguration
Newtonsoft.Json.JsonReaderException:聽Error聽reading聽boolean.聽Unexpected聽token:聽StartObject.聽Path聽'files.exclude['**/*.js']'.
聽聽聽at聽Newtonsoft.Json.JsonReader.ReadAsBoolean()
聽聽聽at聽Newtonsoft.Json.JsonReader.ReadForType(JsonContract聽contract,聽Boolean聽hasConverter)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary聽dictionary,聽JsonReader聽reader,聽JsonDictionaryContract聽contract,聽JsonProperty聽containerProperty,聽String聽id)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader聽reader,聽Type聽objectType,聽JsonContract聽contract,聽JsonProperty聽member,聽JsonContainerContract聽containerContract,聽JsonProperty聽containerMember,聽Object聽existingValue)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty聽property,聽JsonConverter聽propertyConverter,聽JsonContainerContract聽containerContract,聽JsonProperty聽containerProperty,聽JsonReader聽reader,聽Object聽target)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object聽newObject,聽JsonReader聽reader,聽JsonObjectContract聽contract,聽JsonProperty聽member,聽String聽id)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader聽reader,聽Type聽objectType,聽JsonContract聽contract,聽JsonProperty聽member,聽JsonContainerContract聽containerContract,聽JsonProperty聽containerMember,聽Object聽existingValue)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty聽property,聽JsonConverter聽propertyConverter,聽JsonContainerContract聽containerContract,聽JsonProperty聽containerProperty,聽JsonReader聽reader,聽Object聽target)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object聽newObject,聽JsonReader聽reader,聽JsonObjectContract聽contract,聽JsonProperty聽member,聽String聽id)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader聽reader,聽Type聽objectType,聽JsonContract聽contract,聽JsonProperty聽member,聽JsonContainerContract聽containerContract,聽JsonProperty聽containerMember,聽Object聽existingValue)
聽聽聽at聽Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader聽reader,聽Type聽objectType,聽Boolean聽checkAdditionalContent)
聽聽聽at聽Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader聽reader,聽Type聽objectType)
聽聽聽at聽Newtonsoft.Json.Linq.JToken.ToObject(Type聽objectType,聽JsonSerializer聽jsonSerializer)
聽聽聽at聽Newtonsoft.Json.Linq.JToken.ToObject(Type聽objectType)
聽聽聽at聽Newtonsoft.Json.Linq.JToken.ToObject[T]()
聽聽聽at聽Microsoft.PowerShell.EditorServices.Handlers.PsesConfigurationHandler.<Handle>d__11.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.<Handle>d__0.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.<Handle>d__3.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽MediatR.Pipeline.RequestPreProcessorBehavior`2.<Handle>d__2.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽MediatR.Pipeline.RequestPostProcessorBehavior`2.<Handle>d__2.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽MediatR.Pipeline.RequestExceptionProcessorBehavior`2.<Handle>d__2.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽MediatR.Pipeline.RequestExceptionProcessorBehavior`2.<Handle>d__2.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.<Handle>d__2.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.<Handle>d__2.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<<RouteNotification>g__InnerRoute|4_1>d.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteNotification>d__4.MoveNext()
---聽End聽of聽stack聽trace聽from聽previous聽location聽where聽exception聽was聽thrown聽---
聽聽聽at聽System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
聽聽聽at聽System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task聽task)
聽聽聽at聽OmniSharp.Extensions.JsonRpc.InputHandler.<>c__DisplayClass39_0.<<RouteNotification>b__3>d.MoveNext()
2021-02-26聽11:26:15.880聽+01:00聽[INF]聽PSScriptAnalyzer聽settings聽file聽not聽found.聽Falling聽back聽to聽default聽rules

And when fixed

2021-02-26 15:30:02.604 +01:00 [INF] PowerShell runtime version: 7.1.2, edition: Core
2021-02-26 15:30:02.931 +01:00 [INF] highlight handler loaded
2021-02-26 15:30:03.405 +01:00 [ERR] Execution of the following command(s) completed with errors:

    Import-Module ~.vscode\extensions\ms-vscode.powershell-preview-2021.2.1\modules\PowerShellEditorServices\Commands\PowerShellEditorServices.Commands.psd1


2021-02-26 15:30:04.639 +01:00 [INF] Unable to find PSSA settings file at 'c:\PSScriptAnalyzerSettings.psd1'. Loading default rules.
2021-02-26 15:30:04.645 +01:00 [INF] PSScriptAnalyzer settings file not found. Falling back to default rules

I've finally tracked down the definition of this expression syntax. As far as I know it's still undocumented and it's not clear how stable this is intended to be, but we might at least be able to implement something around it given this information.

It's a stable API. It's just... unfortunately... not documented.

It's documented here on the official VSCode docs. Unless we are talking about it being documented somewhere else?

Was this page helpful?
0 / 5 - 0 ratings