AL icon indicating copy to clipboard operation
AL copied to clipboard

Error trying to initialize snapshot debugging

Open waynestevensinsight opened this issue 4 years ago • 6 comments

Describe the bug

I'm trying to "initialize snapshot debugging" from VS Code, and it fails with error "Invalid URI: The format of the URI could not be determined"

To Reproduce

  1. I added the snapshot configuration in launch.json (see below)
  2. I tried to execute command "AL: Initialize snapshot debugging"

Expected behavior

Snapshot debugging should successfully initiate.

Actual behavior

Fails with error - output below.

Versions:

  • AL Language: v8.3.570094
  • Visual Studio Code: 1.64.0-insider
  • Business Central: 19.2
  • List of Visual Studio Code extensions that you have installed: AL Language, AL Object Designer, Live Preview

Here is my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "snapshotInitialize: Microsoft sandbox cloud",
            "type": "al",
            "request": "snapshotInitialize",
            "environmentType": "Sandbox",
            "environmentName": "sandbox",
            "breakOnNext": "WebServiceClient"
        },
        {
            "name": "Microsoft cloud sandbox",
            "request": "launch",
            "type": "al",
            "environmentType": "Sandbox",
            "environmentName": "sandbox",
            "startupObjectId": 22,
            "startupObjectType": "Page",
            "breakOnError": true,
            "launchBrowser": true,
            "enableLongRunningSqlStatements": true,
            "enableSqlInformationDebugger": true,
            "enableSQLInformationDebugger": true
        },
        {
            "name": "Attach: Microsoft cloud sandbox",
            "request": "attach",
            "type": "al",
            "environmentType": "Sandbox",
            "environmentName": "sandbox",
            "breakOnError": true,
            "breakOnRecordWrite": true,
            "enableSqlInformationDebugger": true,
            "enableLongRunningSqlStatements": true,
            "longRunningSqlStatementsThreshold": 500,
            "numberOfSqlStatements": 10,
            "breakOnNext": "WebServiceClient"
        }   
    ]
}

Here is the output after attempting to initialize snapshot:

[2022-01-24 17:19:39.09] Requesting metadata for a snapshot debugging session. 
[2022-01-24 17:19:39.10] Authenticating...
[2022-01-24 17:20:06.50] Authenticated.
[2022-01-24 17:20:06.50] Authenticated as user 'XXXXXXX'. Please note that these credentials are cached. Clear the credentials cache to authenticate as another user.
[2022-01-24 17:20:06.50] Targeting Dynamics 365 Business Central.
[2022-01-24 17:20:06.51] Sending request to https://api.businesscentral.dynamics.com/v2.0/sandbox/snapshotdebugger/snapshotendpointmetadata
[Error - 5:20:09 p.m.] Please report this issue to https://github.com/microsoft/al/issues including information on how to reproduce it, if possible.
Processing of message 'al/initializeSnapshotDebuggerAttach' failed with error: 'Invalid URI: The format of the URI could not be determined.'
Details:
System.UriFormatException: Invalid URI: The format of the URI could not be determined.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at Microsoft.Dynamics.Nav.CodeAnalysis.Utilities.PathUtilities.CreateUriFilePath(String filePath) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Utilities\PathUtilities.cs:line 445
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.Extensions.SnapshotDebuggerAttachInitializeRequestHandler.CreateSourceBreakpointLocationAsync(IList`1 snapPointLocations, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\Extensions\SnapshotDebuggerAttachInitializeRequestHandler.cs:line 111
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.Extensions.SnapshotDebuggerAttachInitializeRequestHandler.ProcessRequestAsync(SnapshotDebuggerAttachInitializeRequest request, Int32 requestId, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\Extensions\SnapshotDebuggerAttachInitializeRequestHandler.cs:line 61
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.LanguageServer.Extensions.NavServerRequestHandler`2.HandleAsync(T request, Int32 requestId, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\LanguageServer\Extensions\NavServerRequestHandler.cs:line 40
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.MessageProtocol.RequestHandlerBase`1.HandleAsync(JToken requestContents, Int32 requestId, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\MessageProtocol\RequestHandlerBase.cs:line 63
   at Microsoft.Dynamics.Nav.EditorServices.Protocol.RequestRegistry.Process(Message message) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.EditorServices.Protocol\Endpoints\RequestRegistry.cs:line 64


waynestevensinsight avatar Jan 24 '22 22:01 waynestevensinsight

Have you defined breakpoints before issuing the command? What is the path of those breakpoints? What if you delete all breakpoints and add the ones that you only need?

kalberes avatar Jan 24 '22 23:01 kalberes

No, I haven't defined any breakpoints. My goal here is to use the AL Profiler (https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-al-profiler-overview) on an OData unbound action API, so I didn't think I needed to define any breakpoints (though I could be wrong, this is my first time working with snapshots).

waynestevensinsight avatar Jan 25 '22 01:01 waynestevensinsight

For profiling you do not need any breakpoints. I was asking because this error can only happen if you have breakpoints defined with unrecognizable path in VsCode before starting a snapshot session. Does this issue happen all the time you issue an F7 on your snapshotInitialize configuration?

kalberes avatar Jan 26 '22 16:01 kalberes

I've this same problem. If I create a new AL project (AL Go!) and define the same lauch.json then no error and I can get profile info. Best regards,

ti-jalopez avatar Apr 06 '22 11:04 ti-jalopez

This issue has been closed because it needs more information and has not had recent activity. Please open a new issue if you believe this has not been resolved and reference the current issue.

thloke avatar Jun 09 '22 07:06 thloke

Thanks @kalberes, having this same issue, removing all breakpoints worked for me.

TeusV avatar Jun 28 '22 11:06 TeusV