Skip to content

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

Closed

Description

@J0F3

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)

Activity

  1. daviwil commented on Nov 26, 2015

    @daviwil
    Contributor

    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.

  2. J0F3 commented on Nov 26, 2015

    @J0F3
    Author

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

  3. daviwil commented on Nov 26, 2015

    @daviwil
    Contributor

    Thank you! I'll get this fixed.

  4. added this to the 0.2.1 milestone on Nov 26, 2015
  5. kilasuit commented on Nov 26, 2015

    @kilasuit
    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.

  6. J0F3 commented on Nov 26, 2015

    @J0F3
    Author

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

  7. kilasuit commented on Nov 26, 2015

    @kilasuit
    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

  8. J0F3 commented on Nov 27, 2015

    @J0F3
    Author

    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

  9. dfinke commented on Nov 27, 2015

    @dfinke
    Contributor

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

    Webdav network drive not work

  10. daviwil commented on Nov 27, 2015

    @daviwil
    Contributor

    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 Jonas Feller (@J0F3), the extension shouldn't fail when such a path is opened. I'll try to get a fix out for that next week.

  11. 15 remaining items

  12. modified the milestones: 0.7.0, on Aug 18, 2016
  13. modified the milestone: on May 24, 2018
  14. SydneyhSmith commented on Mar 17, 2020

    @SydneyhSmith
    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?

  15. ghost added
    Resolution-Inactive
    on Mar 31, 2020
  16. ghost closed this as completedon Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Area-IntelliSenseResolution-Inactive

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions