Skip to content

When a file is opened through WebDav the extension crashes #31

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
J0F3 opened this issue Nov 26, 2015 · 15 comments
Closed

When a file is opened through WebDav the extension crashes #31

J0F3 opened this issue Nov 26, 2015 · 15 comments
Assignees
Labels

Comments

@J0F3
Copy link

J0F3 commented Nov 26, 2015

When a PowerShell File is opened through a WebDav Path (e.g SharePoint Library access through Windows Explorer) the extension crashes with the following error in the EditorServices.log:

FATAL UNHANDLED EXCEPTION:

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.Workspace.ResolveFilePath(String filePath)
   at Microsoft.PowerShell.EditorServices.Workspace.GetFileBuffer(String filePath, String initialBuffer)
   at Microsoft.PowerShell.EditorServices.Host.LanguageServer.HandleDidOpenTextDocumentNotification(DidOpenTextDocumentNotification openParams, EditorSession editorSession, EventContext eventContext)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher`1.<>c__DisplayClass4`1.<AddEventHandler>b__3(Message eventMessage, TSession session, MessageWriter messageWriter)
   at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher`1.<DispatchMessage>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Host.LanguageServer.<ProcessMessage>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Host.MessageLoop.<ListenForMessages>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Host.MessageLoop.<StartMessageLoop>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass3.<Run>b__1(Task t)
   at System.Threading.Tasks.ContinuationTaskFromTask.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.AsyncContext.Run(Func`1 action)
   at Microsoft.PowerShell.EditorServices.Host.MessageLoop.Start()
   at Microsoft.PowerShell.EditorServices.Host.Program.Main(String[] args)
@daviwil
Copy link
Contributor

daviwil commented Nov 26, 2015

Thanks for the report, JOF3! Can you also give me the scheme for the file path that was used? It should be just above the stack trace you copied in the log file. I'll need to add another case in the path validator to allow it.

@J0F3
Copy link
Author

J0F3 commented Nov 26, 2015

Sure. The file path is like the following:
"file://xyz.sharepoint.com%40ssl/DavWWWRoot/sites/Documents/PS%20Scripts/New-VM.ps1"

@daviwil
Copy link
Contributor

daviwil commented Nov 26, 2015

Thank you! I'll get this fixed.

@daviwil daviwil added the Issue-Bug A bug to squash. label Nov 26, 2015
@daviwil daviwil added this to the 0.2.1 milestone Nov 26, 2015
@kilasuit
Copy link
Contributor

There are some considerable issues with opening files from a SharePoint based WebDAV folder when the SharePoint Site is on https not http

Key crux is this against SharePoint Online or on premises? As that makes the difference between being able to do this easily or not due to the different auth in place.

@J0F3
Copy link
Author

J0F3 commented Nov 26, 2015

Cool! Thank you!
In my case it is against SharePoint Online and using https.

@kilasuit
Copy link
Contributor

Also are you on Mac/Windows?

If windows do you have the site marked as a mapped drive? If not you'll need to get that down before you can work with it.

Will try and dig out an article explaining it in more detail but will be late on this evening as I'm off to the London PowerShell User Group tonight

@J0F3
Copy link
Author

J0F3 commented Nov 27, 2015

I am on Windows (Windows 10 with November Update)

I have just tested with a mapped drive. This way it works and the path in the EditorServices.log is like this: "uri": "file:///z%3A/New-VM.ps1"

So the mapped drive is the solution/workaround for this.(?) But I think the extension should not just fail if the file is opened without the mapped drive. Maybe it makes sense that a message is displayed that the extension does not work with the current path

@dfinke
Copy link
Contributor

dfinke commented Nov 27, 2015

Don't know if this may help. A new release if code is out with this fix

Webdav network drive not work

@daviwil
Copy link
Contributor

daviwil commented Nov 27, 2015

Path validation in PowerShell Editor Services still needs to be fixed so that the language service doesn't crash when a WebDAV path is opened.

I agree @J0F3, the extension shouldn't fail when such a path is opened. I'll try to get a fix out for that next week.

@daviwil daviwil added the Up for Grabs Will shepherd PRs. label Dec 1, 2015
@daviwil daviwil modified the milestones: 0.2.1, 0.4.0 Jan 2, 2016
@daviwil daviwil modified the milestones: 0.4.1, 0.4.0 Feb 8, 2016
@daviwil daviwil modified the milestones: 0.5.0, 0.4.1 Feb 17, 2016
@daviwil
Copy link
Contributor

daviwil commented Mar 8, 2016

Hey @J0F3, do you still see this issue when trying to load WebDav files? I apologize it's taken me this long to get back to it.

@J0F3
Copy link
Author

J0F3 commented Mar 9, 2016

Hey @daviwil, No problem. I have just tested it and it unfortunately still happens.

[ERROR] - Method "CurrentDomain_UnhandledException" at line 125 of C:\projects\powershelleditorservices\src\PowerShellEditorServices.Host\Program.cs

System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> System.UriFormatException: Invalid URI: The hostname could not be parsed.

(PowerShell Editor Services Host v0.4.2.264 and Version 0.10.10 of VS Code)

@daviwil
Copy link
Contributor

daviwil commented Mar 9, 2016

Thanks for confirming, I'll have a look and see if I can do something about this for the 0.5.0 release.

@daviwil
Copy link
Contributor

daviwil commented Mar 10, 2016

It looks like the problem here is the odd @ssl suffix in the SharePoint file URI. .NET's System.Uri class considers this invalid so it throws an exception when being parsed. I think I'm going to need to come up with a more general solution for this anyway which doesn't require parsing file paths in the language service.

The only reason I need to parse the paths is so that I can resolve referenced files (through dot-sourcing, etc). My plan is to put that responsibility on the editor, but that will take a bit more work. I'll make this happen for 0.6.

@daviwil daviwil removed this from the 0.6.0 milestone May 11, 2016
@daviwil daviwil modified the milestones: 0.7.0, Backlog Aug 18, 2016
@TylerLeonhardt TylerLeonhardt modified the milestone: Future May 24, 2018
@SydneyhSmith
Copy link
Collaborator

We recently published an update to our extension which has addressed a number of underlying uri issues, would you mind giving it a try and letting us know if you are still hitting this issue?

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Issue-Bug A bug to squash. labels Mar 17, 2020
@ghost
Copy link

ghost commented Mar 31, 2020

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

@ghost ghost added the Resolution-Inactive Will close automatically. label Mar 31, 2020
@ghost ghost closed this as completed Mar 31, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants