CoderAllan / vscode-dgmlviewer

DGML Viewer is a extension for rendering dgml files in Visual Studio code.
MIT License
13 stars 2 forks source link

Render command error: `Cannot read properties of undefined (reading 'name')` #207

Closed FavorMylikes closed 2 years ago

FavorMylikes commented 2 years ago

image

And here is the log detail below about this error.

Command 'DGMLViewer: Render the dgml graph' resulted in an error (Cannot read properties of undefined (reading 'name')) ```console [2022-07-01 15:21:57.749] [exthost] [error] TypeError: Cannot read properties of undefined (reading 'name') at t.DgmlParser.parseDgmlFile (c:\Users\Administrator\.vscode\extensions\coderallan.vscode-dgmlviewer-2.2.3\dist\extension.js:1:12655) at c.execute (c:\Users\Administrator\.vscode\extensions\coderallan.vscode-dgmlviewer-2.2.3\dist\extension.js:1:6196) at c:\Users\Administrator\.vscode\extensions\coderallan.vscode-dgmlviewer-2.2.3\dist\extension.js:1:42575 at o._executeContributedCommand (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:83:62521) at o.$executeContributedCommand (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:83:63225) at s._doInvokeHandler (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:86:13828) at s._invokeHandler (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:86:13512) at s._receiveRequest (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:86:12173) at s._receiveOneMessage (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:86:10843) at c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:86:8949 at g.invoke (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145) at b.deliver (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:2265) at v.fire (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1843) at a.fire (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19025) at c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:102:34863 at g.invoke (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145) at b.deliver (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:2265) at v.fire (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1843) at a.fire (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:19025) at r._receiveMessage (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:23606) at c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:21140 at g.invoke (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:145) at b.deliver (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:2265) at v.fire (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:58:1843) at v.acceptChunk (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:15856) at c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:66:14986 at Socket.R (c:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:102:13798) at Socket.emit (node:events:390:28) at addChunk (node:internal/streams/readable:315:12) at readableAddChunk (node:internal/streams/readable:289:9) at Socket.Readable.push (node:internal/streams/readable:228:10) at Pipe.onStreamRead (node:internal/stream_base_commons:199:23) vscode-dgmlviewer.dgmlViewer {"value":"coderAllan.vscode-dgmlviewer","_lower":"coderallan.vscode-dgmlviewer"} ```
CoderAllan commented 2 years ago

Thanks for the error report. Can you provide a minimal dgml-file that reproduces the issue? It would help a lot in the debugging :-)

FavorMylikes commented 2 years ago

The vcpkg depend-info opencv --dgml > opencv.dgml command creates this file, but I also tried your example file with the same error.

<?xml version="1.0" encoding="utf-8"?>
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
  <Nodes>
    <Node Id="libjpeg-turbo" />
    <Node Id="liblzma" />
    <Node Id="libpng" />
    <Node Id="libwebp" />
    <Node Id="opencv" />
    <Node Id="opencv4" />
    <Node Id="protobuf" />
    <Node Id="quirc" />
    <Node Id="tiff" />
    <Node Id="vcpkg-cmake" />
    <Node Id="vcpkg-cmake-config" />
    <Node Id="vcpkg-get-python-packages" />
    <Node Id="zlib" />
  </Nodes>
  <Links>
    <Link Source="libjpeg-turbo" Target="vcpkg-cmake" />
    <Link Source="libjpeg-turbo" Target="vcpkg-cmake-config" />
    <Link Source="liblzma" Target="vcpkg-cmake" />
    <Link Source="liblzma" Target="vcpkg-cmake-config" />
    <Link Source="libpng" Target="vcpkg-cmake" />
    <Link Source="libpng" Target="vcpkg-cmake-config" />
    <Link Source="libpng" Target="zlib" />
    <Link Source="libwebp" Target="vcpkg-cmake" />
    <Link Source="libwebp" Target="vcpkg-cmake-config" />
    <Link Source="opencv" Target="opencv4" />
    <Link Source="opencv4" Target="libjpeg-turbo" />
    <Link Source="opencv4" Target="libpng" />
    <Link Source="opencv4" Target="libwebp" />
    <Link Source="opencv4" Target="protobuf" />
    <Link Source="opencv4" Target="quirc" />
    <Link Source="opencv4" Target="tiff" />
    <Link Source="opencv4" Target="vcpkg-cmake" />
    <Link Source="opencv4" Target="vcpkg-cmake-config" />
    <Link Source="opencv4" Target="vcpkg-get-python-packages" />
    <Link Source="opencv4" Target="zlib" />
    <Link Source="protobuf" Target="vcpkg-cmake" />
    <Link Source="protobuf" Target="vcpkg-cmake-config" />
    <Link Source="quirc" Target="vcpkg-cmake" />
    <Link Source="quirc" Target="vcpkg-cmake-config" />
    <Link Source="tiff" Target="libjpeg-turbo" />
    <Link Source="tiff" Target="liblzma" />
    <Link Source="tiff" Target="vcpkg-cmake" />
    <Link Source="tiff" Target="vcpkg-cmake-config" />
    <Link Source="tiff" Target="zlib" />
    <Link Source="zlib" Target="vcpkg-cmake" />
  </Links>
</DirectedGraph>
CoderAllan commented 2 years ago

I can't reproduce the error. The file renders correctly when I try it as you can see from the screenshot below. I can see you are using the latest version 2.2.3 of the extension on a Windows machine. What version of Visual Studio Code are you using?

image
CoderAllan commented 2 years ago

I have reproduced the exact error message you get. I did it by introducing an error in the xml file, removing a '<' from the tag or the <?xml.. tag. So you must have a similar error in you xml.

I will see if I can somehow make the error message more user friendly.

image
FavorMylikes commented 2 years ago

Em, I have to say, I got this message at two same windows hosts.

The version of vscode is shown below.

image

Where can I get more detail to debug this problem?

CoderAllan commented 2 years ago

I reproduced the error by trying to render a corrupt xml file. Have you verified that the xml you are trying to render is valid?

FavorMylikes commented 2 years ago

Of course, I rendered it in vs 2019, and everything's ok.

image

CoderAllan commented 2 years ago

Can I get you to place the exact file you are testing with, in the examples folder and create a pull request? That way I can test with the exact same file you are having problems with. Maybe the issue is some hidden characters in the file.

FavorMylikes commented 2 years ago

Done

CoderAllan commented 2 years ago

I cannot reproduce the error with the file you provided. It works fine when I render the file. Try to uninstall the extension and the install it again to see if that helps.

FavorMylikes commented 2 years ago

Reproduce

When I debug it line by line, here is what I see about the XML file header.

1657091683074

And in Hex Editor

1657091797316

I'll upload this file latter.

FavorMylikes commented 2 years ago

BTW, this file is created by some windows command > opencv.dgml.

Maybe this could explain where the character comes from.

CoderAllan commented 2 years ago

I can now reproduce the error with the file that have hidden characters. I will work on a solution that will make vscode-dgmlviewer resilient to that.

CoderAllan commented 2 years ago

Issue fixed in v2.2.4