Skip to content
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

Getting Internal Error for "textDocument/codeAction" request #1603

Open
ManojkumarV opened this issue Nov 27, 2023 · 5 comments
Open

Getting Internal Error for "textDocument/codeAction" request #1603

ManojkumarV opened this issue Nov 27, 2023 · 5 comments

Comments

@ManojkumarV
Copy link

I'm getting internal error while invoking "textDocument/codeAction" request with the following params:
{ context: { diagnostics: [ { range: { start: { line: 1, character: 1, }, end: { line: 1, character: 6, }, }, message: "No grammar constraints (DTD or XML Schema).", code: "NoGrammarConstraints", severity: 4, source: "xml", }, { range: { start: { line: 1, character: 1, }, end: { line: 1, character: 6, }, }, message: "XML document structures must start and end within the same entity.", code: "MarkupEntityMismatch", severity: 1, source: "xml", }, ], only: [ "quickfix", ], }, range: { start: { line: 1, character: 1, }, end: { line: 1, character: 6, }, }, textDocument: { uri: "file:///home/workspace/XML/test.xml", } }

Here is response stack trace

ResponseError: Internal error. at handleResponse (/home/workspace/CODE_IDE/node_modules/vscode-jsonrpc/lib/main.js:449:48) at processMessageQueue (/home/workspace/CODE_IDE/node_modules/vscode-jsonrpc/lib/main.js:276:17) at Immediate.<anonymous> (/home/workspace/CODE_IDE/node_modules/vscode-jsonrpc/lib/main.js:260:13) at processImmediate (node:internal/timers:466:21) at process.callbackTrampoline (node:internal/async_hooks:130:17) { code: -32603, data: 'java.util.concurrent.CompletionException: java.lang.NullPointerException\n' + '\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)\n' + '\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n' + '\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n' + '\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n' + '\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n' + '\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)\n' + '\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n' + '\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n' + '\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\n' + 'Caused by: java.lang.NullPointerException\n' + '\tat org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$23(XMLTextDocumentService.java:512)\n' + '\tat java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)\n' + '\tat java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)\n' + '\tat java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)\n' + '\tat java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)\n' + '\tat java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)\n' + '\tat java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)\n' + '\tat java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)\n' + '\tat org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$24(XMLTextDocumentService.java:518)\n' + '\tat org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)\n' + '\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n' + '\t... 6 more\n' } CODE ACTION PARAMS { textDocument: { uri: 'file:///home/workspace/XML/test.xml' }, range: { start: { line: 1, character: 1 }, end: { line: 1, character: 6 } }, context: { diagnostics: [ [Object], [Object] ], only: [ 'quickfix' ] } } LANGUAGE CLIENT ERROR ResponseError: Internal error. at handleResponse (/home/workspace/CODE_IDE/node_modules/vscode-jsonrpc/lib/main.js:449:48) at processMessageQueue (/home/workspace/CODE_IDE/node_modules/vscode-jsonrpc/lib/main.js:276:17) at Immediate.<anonymous> (/home/workspace/CODE_IDE/node_modules/vscode-jsonrpc/lib/main.js:260:13) at processImmediate (node:internal/timers:466:21) at process.callbackTrampoline (node:internal/async_hooks:130:17) { code: -32603, data: 'java.util.concurrent.CompletionException: java.lang.NullPointerException\n' + '\tat java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)\n' + '\tat java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)\n' + '\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)\n' + '\tat java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)\n' + '\tat java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)\n' + '\tat java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)\n' + '\tat java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)\n' + '\tat java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)\n' + '\tat java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)\n' + 'Caused by: java.lang.NullPointerException\n' + '\tat org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$23(XMLTextDocumentService.java:512)\n' + '\tat java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)\n' + '\tat java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)\n' + '\tat java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)\n' + '\tat java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)\n' + '\tat java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)\n' + '\tat java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)\n' + '\tat java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)\n' + '\tat org.eclipse.lemminx.XMLTextDocumentService.lambda$codeAction$24(XMLTextDocumentService.java:518)\n' + '\tat org.eclipse.lemminx.commons.ModelTextDocuments.lambda$computeModelAsync$0(ModelTextDocuments.java:118)\n' + '\tat java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)\n' + '\t... 6 more\n' }

@angelozerr
Copy link
Contributor

Could youshare please your XML file?

Which vesrion are you isng of vscode-xml?

@ManojkumarV
Copy link
Author

Here is my XML Code

<?xml version="1.0" encoding="UTF-8"?> <manoj>

I'm not using vscode-xml. We are using our own language client. We just cloned this repository, built it using the steps provided and used the Jar file.

Java version
openjdk 11.0.20.1 2023-08-24 OpenJDK Runtime Environment (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04) OpenJDK 64-Bit Server VM (build 11.0.20.1+1-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)

@angelozerr
Copy link
Contributor

I'm not using vscode-xml. We are using our own language client. We just cloned this repository, built it using the steps provided and used the Jar file.

Ok I understand more.

The NPE comes from https://github.com/eclipse/lemminx/blob/def27a72256bd94a57404a58ac219790fe7c831e/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/XMLTextDocumentService.java#L512 and it seems that your LSP client doesn't support the LSP codeActionLiteralSupport and and this case you need to implement a custom LSP command _xml.applyCodeAction

We could fix the NPE but your code actions will not work except if you implement custom LSP command _xml.applyCodeAction

I suggest really that you support codeActionLiteralSupport in your LSP client to follow the LSP specification and yoru code actions will work too with another language server.

We did this work when LSP didn't provide codeActionLiteralSupport but I think we should remove the code with _xml.applyCodeAction

@fbricon @datho7561 what do you think about that?

@ManojkumarV
Copy link
Author

Thanks @angelozerr It worked after adding codeActionLiteralSupport.

@fbricon
Copy link
Contributor

fbricon commented Nov 28, 2023

reopening as Lemminx should be able to gracefully handle clients that don't support codeActionLiteralSupport.

@fbricon fbricon reopened this Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants