Improper LSP URI escaping leads to RuntimeErrors when Diagrams are opened in KEITH #128
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
question
Further information is requested
requires client change
This change is linked to some change on the client side implementation in klighd-vscode
Hello all! As my first issue here, I'd like to thank you for the nice ecosystem you're building here, specially for visualization. Fantastic work :)!
For some contextualization on this issue, I'm the creator and current maintainer of ForSyDe IO. For my PhD research, I just developed a quick outputer of my analysis/synthesis to KGT since I haven't found the actual jars from KlighD (or similar) in maven central. All seemed to be pretty printed nicely and then I downloaded KEITH 0.1.0 nightly for Windows, since I'm running it on my machine.
[Problem]
Once I tried opening the diagram (fairly big one, with 1000+ lines of code), I got two runtime errors related to
URISyntaxException
. I thought that I had messed up something, so I tried checking a subset of my output, until I was sure it was indeed a valid kgt file. After digging in the error itself, I finalized realized the problem was with how the LSP server loads and represents the files from disk: my Windows machine represents the file path likefile:///C:/Users/My Name With Space/..../file.kth
, which cannot be put verbatim as a URI/URL. Sadly, that's exactly what the LSP seems to be doing according to lines 561-580 ofpackage de.cau.cs.kieler.klighd.lsp.KGraphLanguageServerExtension
.Now, I could be wrong, but the root of the problems seems to be that the
xtext
extensions, or the JVM by association, does not encode/escape special characters in a string when you ask it to. In my case, since the user has spaces in it, the LSP complains exactly at the spot where my username has an space. In any case, the result is that I get no diagram and a big red RuntimeException in my beautiful UI.There's another clear evidence that the problem is indeed special characters in the path during encoding: I copied the KGT file into another folder which has no spaces in its path (Users\Public, which I guess exists by default in most Windows machines), and KEITH did its drawing job nicely without hiccups.
[Suggestion]
I think an easy fix is to just replace the offending characters, which won't require any additional effort from extra libraries and others. But wouldn't it be more future-proof if a library (e.g. Guava) is used to encode the URL and "outsource" this problem to more mature libraries? Just giving my 2 cents :).
The text was updated successfully, but these errors were encountered: