Skip to content

LSP services fail with non-ASCII characters in paths #2324

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
Ebola-Chan-bot opened this issue Nov 23, 2019 · 14 comments · Fixed by PowerShell/PowerShellEditorServices#1143
Closed
Labels

Comments

@Ebola-Chan-bot
Copy link

Under PS5.1 mode, typing "Get-" triggers a list of commands starting with that.
批注 2019-11-23 105508
However, with PS7.0, nothing happens:
批注 2019-11-23 105629
What's wrong here?

@ghost ghost added the Needs: Triage Maintainer attention needed! label Nov 23, 2019
@SydneyhSmith
Copy link
Collaborator

@Silver-Fang thanks for opening this issue and providing screenshots. I am having some trouble reproducing this issue but the issue may be do to performance issues we sometimes see in the PowerShell extension i.e. the completions are so slow that it appears they are not coming at all...I would be curious to see if you are able to reproduce this in the PowerShell Preview extension? We recently merged 6+months of stability/performance improvements into preview, and are hoping to ship those in our "stable" PowerShell extension in January. It would also be good to know if you are able to get any other features of the extension working with PS7 i.e. are you able to run code using F8 in the integrated terminal...if not or you are hitting other errors/failures logs would be very helpful...thanks!

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Nov 26, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Nov 26, 2019

@Silver-Fang you should be getting completions in PS 7 the same as you see with PS 5.1; what you're seeing looks like a bug.

If you're able to attach your logs here, we might be able to determine the cause of the issue.

@Ebola-Chan-bot
Copy link
Author

logs.zip
I'm well ready reproducing it in the preview extension

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 7, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Dec 7, 2019

Seeing this in one of the logs:

2019-12-07 11:26:46.041 +08:00 [FTL] Failed to handle notification textDocument/documentSymbol
System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.DocumentSymbolHandler.Handle(DocumentSymbolParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\DocumentSymbolHandler.cs:line 63
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)

@rjmholt
Copy link
Contributor

rjmholt commented Dec 7, 2019

And here:

2019-12-07 11:26:59.825 +08:00 [FTL] Failed to handle notification textDocument/completion
System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\CompletionHandler.cs:line 68
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)

That explains the lack of completions

@rjmholt
Copy link
Contributor

rjmholt commented Dec 7, 2019

Would you be able to provide the path of the file you're trying to complete in?

Alternatively, if you can provide the payload logs, that will show the contents of the LSP messages PSES is being sent causing it to crash.

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Maintainer Attention Maintainer attention needed! labels Dec 10, 2019
@Ebola-Chan-bot
Copy link
Author

Ebola-Chan-bot commented Dec 11, 2019

Would you be able to provide the path of the file you're trying to complete in?

Alternatively, if you can provide the payload logs, that will show the contents of the LSP messages PSES is being sent causing it to crash.

I got it. It's because of non-ansi characters in the path.

[Info  - 下午9:52:05] Finding descriptor for textDocument/didChange
[Info  - 下午9:52:05] Found attributes 1, powershell::file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1
[Info  - 下午9:52:05] Looking for handler for descriptors textDocument/didChange
[Info  - 下午9:52:05] Checking handler textDocument/didChange:Microsoft.PowerShell.EditorServices.Handlers.TextDocumentHandler
[Info  - 下午9:52:05] Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentChangeRegistrationOptions
[Info  - 下午9:52:05] Document Selector [powershell]
[Info  - 下午9:52:05] Handler Selected: Microsoft.PowerShell.EditorServices.Handlers.TextDocumentHandler via [powershell] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcNotificationHandler`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.DidChangeTextDocumentParams, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Info  - 下午9:52:05] Starting: Routing Notification textDocument/didChange
[Info  - 下午9:52:05] Converting params for Notification textDocument/didChange to OmniSharp.Extensions.LanguageServer.Protocol.Models.DidChangeTextDocumentParams
[Error - 下午9:52:05] Failed to handle request textDocument/didChange - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.TextDocumentHandler.Handle(DidChangeTextDocumentParams notification, CancellationToken token) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\TextDocumentHandler.cs:line 54
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteNotification(TDescriptor descriptor, Notification notification, CancellationToken token)
[Info  - 下午9:52:05] Finished: Routing Notification textDocument/didChange in 5ms
[Info  - 下午9:52:05] Finding descriptor for textDocument/completion
[Info  - 下午9:52:05] Found attributes 1, powershell::file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1
[Info  - 下午9:52:05] Looking for handler for descriptors textDocument/completion
[Info  - 下午9:52:05] Checking handler textDocument/completion:Microsoft.PowerShell.EditorServices.Handlers.CompletionHandler
[Info  - 下午9:52:05] Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.CompletionRegistrationOptions
[Info  - 下午9:52:05] Document Selector [powershell]
[Info  - 下午9:52:05] Handler Selected: Microsoft.PowerShell.EditorServices.Handlers.CompletionHandler via [powershell] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.CompletionParams, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.CompletionList, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Info  - 下午9:52:05] Starting: Routing Request (14) textDocument/completion
[Info  - 下午9:52:05] Converting params for Request (14) textDocument/completion to OmniSharp.Extensions.LanguageServer.Protocol.Models.CompletionParams
[Error - 下午9:52:05] Failed to handle notification textDocument/completion - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\CompletionHandler.cs:line 68
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
[Info  - 下午9:52:05] Finished: Routing Request (14) textDocument/completion in 2ms
[Error - 下午9:52:05] Request textDocument/completion failed.
  Message: Internal Error - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.CompletionHandler.Handle(CompletionParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\CompletionHandler.cs:line 68
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
  Code: -32602 
[Info  - 下午9:52:05] Finding descriptor for textDocument/foldingRange
[Info  - 下午9:52:05] Found attributes 1, powershell::file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1
[Info  - 下午9:52:05] Looking for handler for descriptors textDocument/foldingRange
[Info  - 下午9:52:05] Checking handler textDocument/foldingRange:Microsoft.PowerShell.EditorServices.Handlers.FoldingRangeHandler
[Info  - 下午9:52:05] Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentRegistrationOptions
[Info  - 下午9:52:05] Document Selector [powershell]
[Info  - 下午9:52:05] Handler Selected: Microsoft.PowerShell.EditorServices.Handlers.FoldingRangeHandler via [powershell] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRangeRequestParam, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.Container`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRange, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]], OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Info  - 下午9:52:05] Starting: Routing Request (15) textDocument/foldingRange
[Info  - 下午9:52:05] Converting params for Request (15) textDocument/foldingRange to OmniSharp.Extensions.LanguageServer.Protocol.Models.FoldingRangeRequestParam
[Error - 下午9:52:05] Failed to handle notification textDocument/foldingRange - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.TryGetFile(String filePath, ScriptFile& scriptFile) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 180
   at Microsoft.PowerShell.EditorServices.Handlers.FoldingRangeHandler.Handle(FoldingRangeRequestParam request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\FoldingRangeHandler.cs:line 57
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
[Info  - 下午9:52:05] Finished: Routing Request (15) textDocument/foldingRange in 2ms
[Error - 下午9:52:05] Request textDocument/foldingRange failed.
  Message: Internal Error - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.TryGetFile(String filePath, ScriptFile& scriptFile) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 180
   at Microsoft.PowerShell.EditorServices.Handlers.FoldingRangeHandler.Handle(FoldingRangeRequestParam request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\FoldingRangeHandler.cs:line 57
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
  Code: -32602 
[Info  - 下午9:52:05] Finding descriptor for textDocument/codeLens
[Info  - 下午9:52:05] Found attributes 1, powershell::file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1
[Info  - 下午9:52:05] Looking for handler for descriptors textDocument/codeLens
[Info  - 下午9:52:05] Checking handler textDocument/codeLens:Microsoft.PowerShell.EditorServices.Handlers.CodeLensHandlers
[Info  - 下午9:52:05] Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeLensRegistrationOptions
[Info  - 下午9:52:05] Document Selector [powershell]
[Info  - 下午9:52:05] Handler Selected: Microsoft.PowerShell.EditorServices.Handlers.CodeLensHandlers via [powershell] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeLensParams, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeLensContainer, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Info  - 下午9:52:05] Starting: Routing Request (16) textDocument/codeLens
[Info  - 下午9:52:05] Converting params for Request (16) textDocument/codeLens to OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeLensParams
[Info  - 下午9:52:05] Finding descriptor for textDocument/codeAction
[Info  - 下午9:52:05] Found attributes 1, powershell::file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1
[Info  - 下午9:52:05] Looking for handler for descriptors textDocument/codeAction
[Info  - 下午9:52:05] Checking handler textDocument/codeAction:Microsoft.PowerShell.EditorServices.Handlers.CodeActionHandler
[Info  - 下午9:52:05] Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeActionRegistrationOptions
[Info  - 下午9:52:05] Document Selector [powershell]
[Error - 下午9:52:05] Failed to handle notification textDocument/codeLens - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.CodeLensHandlers.Handle(CodeLensParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\CodeLensHandlers.cs:line 64
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
[Info  - 下午9:52:05] Handler Selected: Microsoft.PowerShell.EditorServices.Handlers.CodeActionHandler via [powershell] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeActionParams, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.CommandOrCodeActionContainer, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Info  - 下午9:52:05] Finished: Routing Request (16) textDocument/codeLens in 1ms
[Error - 下午9:52:05] Request textDocument/codeLens failed.
  Message: Internal Error - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.CodeLensHandlers.Handle(CodeLensParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\CodeLensHandlers.cs:line 64
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
  Code: -32602 
[Info  - 下午9:52:05] Starting: Routing Request (17) textDocument/codeAction
[Info  - 下午9:52:05] Converting params for Request (17) textDocument/codeAction to OmniSharp.Extensions.LanguageServer.Protocol.Models.CodeActionParams
[Info  - 下午9:52:05] Result was System.Threading.Tasks.Task`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.CommandOrCodeActionContainer, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]]
[Info  - 下午9:52:05] Response value was OmniSharp.Extensions.LanguageServer.Protocol.Models.CommandOrCodeActionContainer
[Info  - 下午9:52:05] Finished: Routing Request (17) textDocument/codeAction in 0ms
[Info  - 下午9:52:05] Finding descriptor for textDocument/documentSymbol
[Info  - 下午9:52:05] Found attributes 1, powershell::file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1
[Info  - 下午9:52:05] Looking for handler for descriptors textDocument/documentSymbol
[Info  - 下午9:52:05] Checking handler textDocument/documentSymbol:Microsoft.PowerShell.EditorServices.Handlers.DocumentSymbolHandler
[Info  - 下午9:52:05] Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentRegistrationOptions
[Info  - 下午9:52:05] Document Selector [powershell]
[Info  - 下午9:52:05] Handler Selected: Microsoft.PowerShell.EditorServices.Handlers.DocumentSymbolHandler via [powershell] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcRequestHandler`2[[OmniSharp.Extensions.LanguageServer.Protocol.Models.DocumentSymbolParams, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022],[OmniSharp.Extensions.LanguageServer.Protocol.Models.SymbolInformationOrDocumentSymbolContainer, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Info  - 下午9:52:05] Starting: Routing Request (18) textDocument/documentSymbol
[Info  - 下午9:52:05] Converting params for Request (18) textDocument/documentSymbol to OmniSharp.Extensions.LanguageServer.Protocol.Models.DocumentSymbolParams
[Error - 下午9:52:05] Failed to handle notification textDocument/documentSymbol - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.DocumentSymbolHandler.Handle(DocumentSymbolParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\DocumentSymbolHandler.cs:line 63
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
[Info  - 下午9:52:05] Finished: Routing Request (18) textDocument/documentSymbol in 2ms
[Error - 下午9:52:05] Request textDocument/documentSymbol failed.
  Message: Internal Error - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.DocumentSymbolHandler.Handle(DocumentSymbolParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\DocumentSymbolHandler.cs:line 63
   at MediatR.Internal.RequestHandlerWrapperImpl`2.<>c__DisplayClass0_0.<Handle>g__Handler|0()
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(TDescriptor descriptor, Request request, CancellationToken token)
  Code: -32602 
[Info  - 下午9:52:06] Finding descriptor for textDocument/didSave
[Info  - 下午9:52:06] Found attributes 1, powershell::file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1
[Info  - 下午9:52:06] Looking for handler for descriptors textDocument/didSave
[Info  - 下午9:52:06] Checking handler textDocument/didSave:Microsoft.PowerShell.EditorServices.Handlers.TextDocumentHandler
[Info  - 下午9:52:06] Registration options OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentSaveRegistrationOptions
[Info  - 下午9:52:06] Document Selector [powershell]
[Info  - 下午9:52:06] Handler Selected: Microsoft.PowerShell.EditorServices.Handlers.TextDocumentHandler via [powershell] (targeting OmniSharp.Extensions.JsonRpc.IJsonRpcNotificationHandler`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.DidSaveTextDocumentParams, OmniSharp.Extensions.LanguageProtocol, Version=0.14.0.0, Culture=neutral, PublicKeyToken=6d868dff454e6022]])
[Info  - 下午9:52:06] Starting: Routing Notification textDocument/didSave
[Info  - 下午9:52:06] Converting params for Notification textDocument/didSave to OmniSharp.Extensions.LanguageServer.Protocol.Models.DidSaveTextDocumentParams
[Error - 下午9:52:06] Failed to handle request textDocument/didSave - System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.ResolveFilePath(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 438
   at Microsoft.PowerShell.EditorServices.Services.WorkspaceService.GetFile(String filePath) in D:\a\1\s\src\PowerShellEditorServices\Services\Workspace\WorkspaceService.cs:line 144
   at Microsoft.PowerShell.EditorServices.Handlers.TextDocumentHandler.Handle(DidSaveTextDocumentParams notification, CancellationToken token) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\TextDocumentHandler.cs:line 123
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteNotification(TDescriptor descriptor, Notification notification, CancellationToken token)
[Info  - 下午9:52:06] Finished: Routing Notification textDocument/didSave in 1ms

If I use a path like D:\Completion.ps1, it works just fine.
Modern apps should fully support Unicode. Is it a bug of PS Extension or VSCode?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 11, 2019
@TylerLeonhardt
Copy link
Member

Hi @Silver-Fang, can you follow the steps on uploading payload logs? That will help us understand if it's PS Extension or VSCode.

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Dec 11, 2019
@rjmholt rjmholt changed the title How to have VSCode show command list for PS7.0 when typing? LSP services fail with non-ASCII characters in paths Dec 12, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Dec 12, 2019

@Silver-Fang would you also be able to provide one of the paths in the log in its non-url-escaped form?

@Ebola-Chan-bot
Copy link
Author

payload.txt

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 14, 2019
@rjmholt
Copy link
Contributor

rjmholt commented Dec 14, 2019

Thanks!

@TylerLeonhardt
Copy link
Member

It's interesting... that does come in correctly at first:

Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%B5%8B%E8%AF%95.ps1",
        "version": 9
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 0,
                    "character": 0
                },
                "end": {
                    "line": 0,
                    "character": 0
                }
            },
            "rangeLength": 0,
            "text": "a"
        }
    ]
}
# works
PS > [System.Uri]::new("file:///d%3A/%E6%B5%8B%E8%AF%95.ps1")

AbsolutePath   : /d%3A/%E6%B5%8B%E8%AF%95.ps1
AbsoluteUri    : file:///d%3A/%E6%B5%8B%E8%AF%95.ps1/d%3A/%E6%B5%8B%E8%AF%95.ps1
LocalPath      : /d:/测试.ps1
Authority      : /d%3A/%E6%B5%8B%E8%AF%95.ps1
HostNameType   : Basic
IsDefaultPort  : True
IsFile         : True
IsLoopback     : False
PathAndQuery   : /d%3A/%E6%B5%8B%E8%AF%95.ps1
Segments       : {/, d%3A/, %E6%B5%8B%E8%AF%95.ps1}
IsUnc          : False
Host           : /d%3A/%E6%B5%8B%E8%AF%95.ps1
Port           : -1
Query          :
Fragment       :
Scheme         : file
OriginalString : file:///d%3A/%E6%B5%8B%E8%AF%95.ps1
DnsSafeHost    : /d:/测试.ps1
IdnHost        : /d:/测试.ps1
IsAbsoluteUri  : True
UserEscaped    : False
UserInfo       :

but the AbsoluteUri seems a bit odd...

@TylerLeonhardt
Copy link
Member

Ah hah... This issue is in PowerShell Editor Services... The problem is that we are calling ToString on a Uri and then parsing it again with Uri.

Here's the repro:

[System.Uri]::new("file:///d%3A/%E6%B5%8B%E8%AF%95.ps1").ToString()
file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1

[uri]::new("file://%2Fd%3A%2F测试.ps1/d%3A/测试.ps1")
MethodInvocationException: Exception calling ".ctor" with "1" argument(s): "Invalid URI: The hostname could not be parsed."

@TylerLeonhardt
Copy link
Member

Unfortunately there's more here... the Omnisharp library we depend on uses ToString as well so I will have to work with them on a fix. This is my top priority right now but please be aware that the holidays are approaching so progress will be delayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants