-
Notifications
You must be signed in to change notification settings - Fork 146
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
org.eclipse.lsp4j.jsonrpc.MessageIssueException: Message could not be parsed with special character “
#616
Comments
“
Thanks for the bug report. Can you provide the LSP message that fails, ie the json that failed? |
Yes sure, here the completion item that XML language server returns: {
"label": "default-context-path",
"kind": 10,
"documentation": {
"kind": "markdown",
"value": "When specified, this element provides a default context path of the web application. An empty value for this element must cause the web application to be deployed at the root for the container. Otherwise, the default context path must start with a “/“ character but not end with a “/“ character. Servlet containers may provide vendor specific configuration options that allows specifying a value that overrides the value specified here.\r\n\r\nSource: [web-app_4_0.xsd](file:/C:/Users/azerr/eclipse-workspace2/.metadata/.plugins/org.eclipse.pde.core/Eclipse%20Application/org.eclipse.osgi/538/0/.cp/dtdsAndSchemas/web-app_4_0.xsd)"
},
"filterText": "default-context-path",
"insertTextFormat": 2,
"textEdit": {
"range": {
"start": {
"line": 6,
"character": 2
},
"end": {
"line": 6,
"character": 2
}
},
"newText": "\u003cdefault-context-path\u003e$1\u003c/default-context-path\u003e$0"
}
} The problem comes from with the value:
Please note vscode support that. |
This is looking like a charset issue. Not sure why LSP4J is failing on this but VSCode isn't. I don't know how to test your code in place, but I note in your original issue that you are on Windows which has different defaults. There may be a getBytes() in LSP4J that is missing a charset parameter. Do you know if the language server is including |
Interestingly, a simple test case MessageJsonHandler jsonHandler =
new MessageJsonHandler(ServiceEndpoints.getSupportedMethods(TextDocumentService.class));
jsonHandler.setMethodProvider(requestId -> "textDocument/completion");
ByteArrayOutputStream output = new ByteArrayOutputStream();
StreamMessageConsumer messageConsumer = new StreamMessageConsumer(output, jsonHandler);
CompletionItem completionItem = new CompletionItem("default-context-path");
completionItem.setDocumentation(new MarkupContent("markdown",
"When specified, this element provides a default context path of the web application. An empty value for this element must cause the web application to be deployed at the root for the container. Otherwise, the default context path must start with a “/“ character but not end with a “/“ character. Servlet containers may provide vendor specific configuration options that allows specifying a value that overrides the value specified here.\r\n\r\nSource: [web-app_4_0.xsd](file:/C:/Users/azerr/eclipse-workspace2/.metadata/.plugins/org.eclipse.pde.core/Eclipse%20Application/org.eclipse.osgi/538/0/.cp/dtdsAndSchemas/web-app_4_0.xsd)"));
ResponseMessage responseMessage = new ResponseMessage();
responseMessage.setId("1");
responseMessage.setResult(Either.forLeft(List.of(completionItem)));
messageConsumer.consume(responseMessage);
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
try (StreamMessageProducer messageProducer = new StreamMessageProducer(input, jsonHandler))
{
messageProducer.listen(message ->
{
assertEquals(responseMessage, message);
});
} works just fine. Also, I could find no encoding-related issues by inspecting the code in Are you sure that the |
The problems comes from client side with LSP4E in Eclipse IDE and it works with vscode. XML language server uses LSP4J and Eclipse IDE LSP4E too. So the problem comes from LSP4J on client side. I'm pretty sure that the problem comes from with the @mickaelistria could you help us with this problem please. |
shouldnt this be reproducible with a simple unit test |
Thanks for the details. That's even more strange, because I cannot reproduce the issue with this completion item using a test language server (based on |
does lemmix send a charset in header? |
also: do we have the cause for the MalformedJsonException |
We don't write any component which does that,just using LSPJ4 without extra configuration. I tested in Eclipse IDE && WWD which support TypeScript (it use vscode-languageserver I think), it works but the language server returns:
|
can you debug lsp4e for the MalformedJsonException |
i tried to reproduce with lemmix and lsp4e but i failed so far. |
@angelozerr Can you also try to execute the test case from #616 (comment) on your workstation? |
@angelozerr Can you please provide files and steps to reproduce this issue in Eclipse IDE with latest snapshots of Wild Web Developer and LSP4E? |
My bad, you are right it works. In my case I start LemMinx with an Eclipse debug launch (to debug it easily) and I have this problem. I think it's a problem with an Eclipse debug launch, but user doesn't use it, so it is not an issue. We can close the issue. Sorry for the noise and many thanks for your relevant feedback! |
But it should work in this case too |
I tested with utf8 and no issue |
As soon as I will have time to debug LSP4E, I will give you feedback. |
In LemMinx we provide XML completion based on XSD / DTD. When documentation coming from XSD documentation contains
“
, the XML language server send this JSON response but when the client (Eclipse IDE / LSP4E) try to parse the message, it throws teh follwing exception:The text was updated successfully, but these errors were encountered: